Inheritance |
|
The IPR viewer progressively refines a render, first providing a rough view of the rendered image and eventually providing the fully rendered image. When you change a shader value, move an object, etc., the viewer will re-render the image.
When you Ctrl+click on a pixel in the rendered image, Houdini searches
$HOUDINI_PATH
for scripts/ipr/pickpixel.py
and runs it. The version of
this file that ships with Houdini pops up the shader contributing the pixel, or
an information window if there is is no shader. If Houdini cannot find that
Python file it then looks for the Hscript file scripts/ipr/pickpixel.cmd
.
When you drag a SHOP node onto the rendered image, Houdini searches for
and runs scripts/ipr/dragdrop.py
. By default, this script assigns the
SHOP to the object contributing the pixel. If it cannot find a Python
version, Houdini then looks for scripts/ipr/dragdrop.cmd
.
Note that shelf scripts can access the last location the user clicked on with hou.IPRViewer.lastClickLocation.
Methods ¶
isPaused()
→ bool
Indicates whether the IPR session is paused. If there is no active session, this returns false.
isRendering()
→ bool
Indicates whether the IPR session has an render in progress. Returns True even if the render is paused.
isActive()
→ bool
Indicates whether an active IPR sessions exists.
killRender()
Kills the active IPR session (if there is one).
pauseRender()
Pauses the active IPR session (if there is one).
resumeRender()
Resumes the active IPR session (if there is one).
startRender()
Start a new render if there is no active IPR session or issue a re-render if there is one.
isPreviewOn()
→ bool
Return whether or not the Preview checkbox is checked. When it is unchecked, the viewer will not progressively refine the image using IPR, and will instead use the rendering engine from the ROP node to render it.
See also hou.IPRViewer.setPreview.
setPreview(on)
Check or uncheck the Preview checkbox.
See hou.IPRViewer.isPreviewOn for more information.
isAutoSaveOn()
→ bool
Returns whether or not the Auto Save toggle is selected. When turned on, IPR will periodically save the render progress to the auto save file path. The time between saves can be configured by setting the auto save time.
See also hou.IPRViewer.setAutoSave.
setAutoSave(on)
Set or unset the Auto Save toggle.
See hou.IPRViewer.isAutoSaveOn for more information.
autoSavePath()
→ str
Returns the render save path. This is the path that is used when the IPR viewer is set to automatically save render progress to disk.
See also hou.IPRViewer.setSavePath.
setAutoSavePath(path)
Sets the render progress save path.
See also hou.IPRViewer.autoSavePath for more information.
autoSaveTime()
→ float
Returns the time between IPR auto saves in seconds. When auto saving is on, a render progress image is written out at this rate.
See also hou.IPRViewer.setAutoSaveTime.
setAutoSaveTime(float)
Sets the auto save time in seconds.
See also hou.IPRViewer.autoSaveTime for more information.
isAutoUpdateOn()
→ bool
Return whether or not the Auto-Update checkbox is checked. When it is unchecked, the viewer will not refresh when objects, shaders, lights, etc. change. In this case, you can force a re-render by clicking on the Render button.
See also hou.IPRViewer.setAutoUpdate.
setAutoUpdate(on)
Check or uncheck the Auto-Update checkbox.
See hou.IPRViewer.isAutoUpdateOn for more information.
delay()
→ float
Return the contents of the viewer’s Delay field. This value determines how long Houdini waits between when you change a parameter value and when it starts re-rendering.
See also hou.IPRViewer.setDelay and hou.IPRViewer.updateTime.
setDelay(time)
Set the contents of the viewer’s Delay field.
See hou.IPRViewer.delay for more information.
updateTime()
→ float
Return the contents of the viewer’s Update Time field. This value determines approximately how long each progressive refinement should take. Smaller values will produce more progressive renders where detail is added more gradually.
See also hou.IPRViewer.setUpdateTime and hou.IPRViewer.delay.
setUpdateTime(time)
Set the contents of the viewer’s Update Time field.
See hou.IPRViewer.updateTime for more information.
lastClickLocation()
→ (int
, int
)
Return the x and y coordinates for the pixel location where the user last clicked in the IPR viewer. Note that this location might be outside the image: the x and y coordinates can be negative and can be greater than or equal to the image resolution. Note that if the user never clicked in the viewer, the x and y coordinates will be negative.
You would typically call this method from a shelf script. For example, a user can click on a pixel in the IPR viewer and then click on the shelf to perform an action on that pixel (e.g. display the shader parameters, assign a shader, etc.).
Use hou.IPRViewer.imageResolution to get the valid range for pixel coordinates.
Note that when you Ctrl-click on a pixel, Houdini searches $HOUDINI_PATH
for scripts/ipr/pickpixel.py
and runs it. This script can access the
viewer with kwargs["viewer"]
and the location where the user clicked with
kwargs["position"]
.
The following script opens a floating parameter window for the shader corresponding to the pixel the user last clicked on.
viewer = hou.ui.paneTabOfType(hou.paneTabType.IPRViewer) px, py = viewer.lastClickLocation() if (px < 0 or px > viewer.imageResolution()[0] or py < 0 or py >= viewer.imageResolution()[1]): hou.ui.displayMessage("Click on the image and then run this script again") else: material = viewer.materialNode(px, py) if material is not None: parm_window = hou.ui.curDesktop().createFloatingPaneTab( hou.paneTabType.Parm) parm_window.setCurrentNode(material) parm_window.setPin(True) else: hou.ui.displayMessage("Click on an object to bring up the shader.")
ropNode()
→ hou.RopNode or None
Return the ROP node that is selected in the viewer, or None
if nothing
is selected.
setRopNode(rop_node)
Set the ROP node to use for rendering.
imageResolution()
→ (int
, int
)
Return the resolution of the image.
Raises hou.OperationFailed if the viewer does not contain an image.
cropRegion()
→ (float
, float
, float
, float
)
Return the x0
, x1
, y0
, and y1
normalized coordinates of the
subregion that is selected, where (x0, y0)
is the bottom-left corner
and (x1, y1)
is the top-right corner of the subregion.
You can optionally tell the IPR viewer to only re-render only a portion of the image. To select a subportion of the image, hold down shift and select the box.
Note that the bottom-left corner is (0.0, 0.0)
and the top-right corner
is (1.0, 1.0)
. For example, if the entire image is being rendered, this
method returns (0.0, 1.0, 0.0, 1.0)
.
planes()
→ tuple
of str
Return the names of the image planes in the rendered output.
Note that the special Op_Id
image plane contains the
hou.Node.sessionId ids of the object nodes in the image. -1
indicates that there is no object node associated with the pixel.
Use hou.IPRViewer.objectNode to access the object corresponding to
that id.
Similarly, the Prim_Id
plane contains the hou.Prim.number ids
of the primitives in the image. Use hou.IPRViewer.prim to access
the primitive corresponding to that id.
Raises hou.OperationFailed if the viewer does not contain an image.
displayedPlane()
→ str
Return the name of the currently-displayed image plane in the rendered output.
Note that the special Op_Id
image plane contains the
hou.Node.sessionId ids of the object nodes in the image. -1
indicates that there is no object node associated with the pixel.
Use hou.IPRViewer.objectNode to access the object corresponding to
that id.
Similarly, the Prim_Id
plane contains the hou.Prim.number ids
of the primitives in the image. Use hou.IPRViewer.prim to access
the primitive corresponding to that id.
Raises hou.OperationFailed if the viewer does not contain an image.
pixel(plane_name, x, y)
→ tuple
of float
Return the value of a pixel in one plane of the image. This method returns a tuple of 1 to 4 floats, depending on the type of image plane.
Note that the color plane is named C
.
Raises hou.OperationFailed if the plane name is invalid, the pixel location is outside the image, or the viewer does not contain an image.
You can determine the number of components in the image plane using the
following: len(viewer.pixel(plane_name, 0, 0))
.
>>> viewer.pixel("C", 300, 200) (0.69970703125, 0.46728515625, 0.289794921875, 1.0)
pixels(plane_name)
→ tuple
of tuple
of float
Returns the value of all pixels in one plane of the image. This method returns a tuple of tuples of 1 to 4 floats, depending on the type of image plane. The results are in row-major order, starting at the bottom left corner of the IPR image.
Note that the color plane is named C
.
Raises hou.OperationFailed if the plane name is invalid or the viewer does not contain an image.
>>> all_pixels = viewer.pixels("C") >>> width = viewer.imageResolution()[0] >>> all_pixels[width*200 + 300] (0.69970703125, 0.46728515625, 0.289794921875, 1.0)
evaluatedStyleSheetJSON(x, y)
→ str
Returns a JSON string describing the material style sheet at a given pixel. If no style sheet is active, an empty string is returned.
evaluatedStyleSheetPaths(x, y)
→ tuple
of str
Returns a list of paths to the styles that contribute to the style sheet at the current pixel.
saveFrame(file_path, snapshot=0, xres=-1, yres=-1, color='C', alpha='C', scope='*', lut='', gamma=1.0, convert=True)
→ bool
Saves the current IPR render to the specified file path. It is possible to save an in progress/incomplete render.
The output image type is inferred from the file extension on the provided
file path. The snapshot
parameter controls which IPR snapshot to save. A
value of 0 indicates the active render.
The native IPR resolution is used by default, however a custom resolution
can be specified with the xres
and yres
parameters. The color
and
alpha
parameters control which render planes are used when writing RGBA
images like .jpg or .png. If a deep image format such as .pic or .exr
is used, the scope parameter can be used to specify which image planes
to include in the output.
objectNode(x, y)
→ hou.ObjNode or None
Return the object node contributing the pixel at the specified location,
or None
if there is no object at the pixel or if the pixel location
is outside the image bounds
The following function returns the SOP node containing the geometry that contributes the pixel to the final image:
def sopNode(viewer, x, y): obj_node = viewer.objectNode(x, y) return (obj_node.renderNode() if obj_node is not None else None)
Raises hou.OperationFailed if the viewer does not contain an image.
prim(x, y)
→ hou.Prim or None
Return the geometry primitive contributing the pixel at the specified
location, or None
if there is nothing at the pixel or if the pixel
location is outside the image bounds
Raises hou.OperationFailed if the viewer does not contain an image.
materialNode(x, y)
→ hou.ShopNode or None
Return the SHOP node contributing the pixel at the specified location, or
None
if there is nothing at the pixel, the pixel location is outside the
image bounds, or there is no shader on the geometry.
This method first checks the primitive corresponding to the pixel and
returns the SHOP corresponding to its shop_materialpath
attribute.
If the primitive does not have this attribute then it returns the SHOP
assigned to the object. If no SHOP is assigned to the object, it returns
None
.
Raises hou.OperationFailed if the viewer does not contain an image.
Color Correction ¶
These functions set or query the OpenColorIO settings for the viewer (see OpenColorIO Support).
usingOCIO()
→ bool
Query if OpenColorIO is being used for color correction in the viewer.
setUsingOCIO(enable)
Enable or disable OpenColorIO for color correction in the viewer.
setOCIODisplayView(display="", view="")
Set the OpenColorIO display name, view name, or both. The display and view together define the output colorspace for the viewer, and any number of color transforms (Looks) to be performed on the linear viewport image.
getOCIODisplay()
→ str
Return the current OpenColorIO display used for color correction.
getOCIOView()
→ str
Return the current OpenColorIO view used for color correction.
Methods from hou.Pane ¶
tabOfType(type, index=0)
→ hou.PaneTab or None
Find and return a pane tab with the desired type, or None
if no such tab
exists in the pane.
If there are multiple tabs in the pane with the desired type, then the
first found tab is returned. Use index
to return the other tabs. For
example, use index=0
to return the first found tab, use index=1
to
return the second found tab, etc.
See also hou.ui.paneTabOfType.
currentTab()
→ hou.PaneTab
Return the currently focused pane tab.
See also hou.PaneTab.setIsCurrentTab.
createTab(type)
→ hou.PaneTab
Create a new pane tab with the desired type and return it. The new pane tab will be current (i.e. it will be the pane tab that’s open).
splitHorizontally()
→ hou.Pane
Split the pane, adding a new pane to the right, and return the new pane. The new pane will have a single tab whose type is the same as the type of this pane’s current tab.
See also hou.Pane.splitVertically.
splitVertically()
→ hou.Pane
Split the pane, adding a new pane to the bottom, and return the new pane. The new pane will have a single tab whose type is the same as the type of this pane’s current tab.
See also hou.Pane.splitHorizontally.
desktop()
→ hou.Desktop or None
Return the desktop in which this pane exists, or None
if it is in
a floating panel that’s not attached to the desktop.
isMaximized()
→ bool
Return True
if this pane is maximized.
setIsMaximized(on)
Set the maximized state of this pane.
getSplitParent()
→ hou.Pane or None
Return the parent split pane if the Pane is nested under a split.
getSplitChild(self,index)
→ hou.Pane or None
Return the split child Pane at index if the Pane is a split.
splitSwap()
Swap the left and right panes of an horizontal split Pane. Swap the top and bottom panes of a vertical split Pane.
splitRotate()
Turn an horizontal split Pane into a vertical split Pane.
isSplitMinimized()
→ bool
Return True if the Pane is minimized on the split. A split can’t be minimized and maximized at the same time. In its default state, a split is not minimized and not maximized.
isSplitMaximized()
→ bool
Return True if the Pane is maximized on the split. A split can’t be minimized and maximized at the same time. In its default state, a split is not minimized and not maximized.
setIsSplitMaximized(on)
→ bool
Set the maximized state of a split.
isSplit()
→ bool
Return True if the pane is a split.
setSplitFraction(self,fraction)
Set the split fraction of the parent split.
getSplitFraction(self,fraction)
→ double
Return the split fraction of the parent split.
setSplitDirection(self,dir)
Set the split direction of the parent split.
getSplitDirection(self,dir)
→ double
Return the split direction of the parent split.
isShowingPaneTabs()
→ bool
Return True if the Pane is showing pane tabs.
setShowPaneTabs(self,on)
Show or Hide the pane tabs bar.
This method is deprecated in favor of showPaneTabs
.
showPaneTabs(self,on)
Show or Hide the pane tabs bar.
isShowingPaneTabsStow()
→ bool
Return True if the Pane is showing the pane tabs stow bar when pane tabs are hidden.
showPaneTabsStow(self,on)
Show or Hide the pane tabs stow bar button when pane tabs are hidden.
qtParentWindow()
→ QWidget
Return a PySide2.QtWidgets.QWidget
instance that represents the window
containing the pane.
qtScreenGeometry()
→ QRect
Return the geometry of the pane as a PySide2.QtCore.QRect
object. The x
and y
properties of the returned QRect
object
point to the top-left corner of the pane in screen coordinates.