hou.IPRViewer
class
An interactive preview render (IPR) window.
Inheritence: hou.Pane >
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
Methods inherited from hou.Pane: showPaneBar, showsPaneBar, tabs, splitHorizontally, tabOfType, sendKey, setIsMaximized, swapWithPane, splitVertically, createTab, desktop, isMaximized, currentTab
isIPREnabled(self)→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.enableIPR.
enableIPR(self, on)-
Check or uncheck the Preview checkbox.
See hou.IPRViewer.isIPREnabled for more information.
isAutoUpdateOn(self)→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(self, on)-
Check or uncheck the Auto-Update checkbox.
See hou.IPRViewer.isAutoUpdateOn for more information.
delay(self)→ 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(self, time)-
Set the contents of the viewer’s Delay field.
See hou.IPRViewer.delay for more information.
updateTime(self)→ 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(self, time)-
Set the contents of the viewer’s Update Time field.
See hou.IPRViewer.updateTime for more information.
lastClickLocation(self)→ (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_PATHforscripts/ipr/pickpixel.pyand runs it. This script can access the viewer withkwargs["viewer"]and the location where the user clicked withkwargs["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(self)→ hou.RopNode orNone-
Return the ROP node that is selected in the viewer, or
Noneif nothing is selected. imageResolution(self)→ (int,int)-
Return the resolution of the image.
Raises hou.OperationFailed if the viewer does not contain an image.
cropRegion(self)→ (float,float,float,float)-
Return the
x0,x1,y0, andy1normalized 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(self)→tupleofstr-
Return the names of the image planes in the rendered output.
Note that the special
Op_Idimage plane contains the hou.Node.sessionId ids of the object nodes in the image, plus 1. 0 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_Idplane contains the hou.Prim.number ids of the primitives in the image, plus 1. Use hou.IPRViewer.prim to access the primitive corresponding to that id.Raises hou.OperationFailed if the viewer does not contain an image.
pixel(self, plane_name, x, y)→tupleoffloat-
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)
objectNode(self, x, y)→ hou.ObjNode orNone-
Return the object node contributing the pixel at the specified location, or
Noneif there is no object at the pixel or if the pixel location is outside the image boundsThe 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(self, x, y)→ hou.Prim orNone-
Return the geometry primitive contributing the pixel at the specified location, or
Noneif there is nothing at the pixel or if the pixel location is outside the image boundsRaises hou.OperationFailed if the viewer does not contain an image.
materialNode(self, x, y)→ hou.ShopNode orNone-
Return the SHOP node contributing the pixel at the specified location, or
Noneif 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_materialpathattribute. 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 returnsNone.Raises hou.OperationFailed if the viewer does not contain an image.