Class SoGLRenderAction
- Direct Known Subclasses:
SoHighlightRenderAction
The viewer classes, SoWin/SoXt/SoQtExaminerViewer etc, automatically create a render action for you and also expose most of the rendering options for convenience. See also the viewer component classes (SceneExaminer etc).
Traversal order
Nodes from the scene graph are traversed using depth-first traversal. However, traversal of some objects may be delayed, depending on transparency options.
A transparent object is an object:
- With a material that has a transparency value set either by a material node or a vertex property node.
or
- With a texture that has an alpha value < 1.
Open Inventor automatically detects these cases.
The rendering order for transparent objects depends on the transparency "type" (transparency rendering method) assigned to each object. A transparency type may be set for the entire scene graph using the SoGLRenderAction
or
invalid reference
SoWinRenderArea
There are several special cases including:
- Transparency type SORTED_PIXEL.
The environment variable OIV_NO_SHADER_LAYERS_BLEND allows you to disable the use of a fragment shader for this technique. - SoRenderList nodes, e.g. SoOctreeOrdering.
Objects that are delayed are generally rendered in the sequence below, but other objects are rendered in various specific orders, not in scene graph order. See the specific node for details.
The general rendering order is:
- Scene graph traversal
All objects not in one of the following categories, specifically including transparent objects using the NO_SORT transparency type. - FastEdit KEEP_ZBUFFER objects
Objects under anSoSeparator
node with fastEditing field set to KEEP_ZBUFFER. - Opaque delayed objects
- Transparent delayed objects
Objects using transparency types OPAQUE_FIRST or SORTED_PIXEL. Note that by default the OpenGL depth buffer is not updated while rendering these objects. - Transparent sorted objects
Objects using transparency types SORTED_OBJECT These objects are sorted by the distance of their bounding box from the camera, then rendered in back-to-front order. Note that by default the OpenGL depth buffer is not updated while rendering these objects. - Annotation delayed objects
Objects under anSoAnnotation
node. - FastEdit CLEAR_ZBUFFER objects
Objects under anSoSeparator
node with fastEditing field set to CLEAR_ZBUFFER.
Elements
Sets: SoDecimationTypeElement
, SoDecimationPercentageElement
, SoUpdateAreaElement
, SoRenderPassElement, SoViewportRegionElement
, SoLogicalViewportElement
Notes & Limitations:
- Since OpenInventor 10.0, most rendering and caching mechanisms are managed by
SoSceneManager
, which means that aSoGLRenderAction
cannot be used outside of the render() call ofSoSceneManager
. Hence, manually calling apply() on anSoGLRenderAction
can only be done during the traversal of the scene graph, for example inside anSoCallback
. Calling apply() outside of this case leads to undefined behavior and will potentially result in incorrect rendering, performance issues, memory leaks and crashes.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Possible return codes from a render abort callback.static enum
Two bits are stored.static enum
Fast edit traversal types.static enum
Invalidate cache mode.static enum
Transparency rendering algorithm.Nested classes/interfaces inherited from class com.openinventor.inventor.actions.SoAction
SoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndices
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
Field Summary
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
abortNow()
void
enableDepthPeeling3D
(boolean flag) Use 3D texturing instead of 2D for the fixed functionality emulation in depth peeling.static void
enableElement
(Class<? extends Inventor> t, int stkIndex) static int
Generates and returns a new cache context id.getCache()
Returns the cache that has been set withsetCache()
int
Returns the OpenGL cache context id for this action.int
float
Gets decimation percentage, the value should be a number between 0.0 and 1.0.Gets decimation type.boolean
Returns whether delayed transparent objects update the depth buffer.int
Get the current pass of depth peeling, -1 if not doing depth peeling.Returns fast editing save policy used when rendering.int
Returns the current frame counter.Returns the current cache invalidation mode.Returns current logical viewport region.int
Gets number of rendering passes for multipass rendering.boolean
Returns true if remote rendering is being done.int
Returns the number of rendering passes used when transparency type isSORTED_PIXEL
.Returns transparency quality level to use when rendering.SbVec2f[]
Returns the current update area.Returns viewport region to use for rendering.boolean
Calls handleTransparency(false, false).boolean
handleTransparency
(boolean isTransparent) Calls handleTransparency(isTransparent, false).boolean
handleTransparency
(boolean isTransparent, boolean isLinesOrPoints) boolean
Returns whether the OpenGL alpha test is enabled for rendering.boolean
Return true if depth peeling is active.boolean
Returns a flag indicating whether intermediate results are displayed after each antialiasing pass for progressive improvement.boolean
Deprecated.As of Open Inventor 101.0.0.0.static boolean
Calls isSortedLayersSupported((com.openinventor.inventor.misc.SoState)null).static boolean
isSortedLayersSupported
(SoState state) Indicates ifSORTED_PIXEL
transparency is supported by your graphics board on the current context.static boolean
isUsedCacheContext
(int context) Returns true if the specified cache context id is currently used by anySoGLRenderAction
.void
Calls resetFrameCounter((int)0).void
resetFrameCounter
(int count) Reset the frame counter.void
setAlphaTest
(boolean flag) Enable or disable the OpenGL alpha test for rendering.void
Sets the main cache to use with this render action.void
setCacheContext
(int context) Sets the OpenGL cache context.void
Calls setDecimationValue(type, (float)1.0).void
setDecimationValue
(SoDecimationTypeElement.Types type, float percentage) Sets decimation percentage, the value should be a number between 0.0 and 1.0 Useful for reducing the number of triangles rendered in the scene.void
setDelayedObjDepthWrite
(boolean flag) Control whether delayed transparent objects update the depth buffer.void
Calls setFastEditSavePolicy(policy, false).void
setFastEditSavePolicy
(SoGLRenderAction.FastEditSavePolicies policy, boolean fastEditDelayedObjects) Sets fast editing save policy to use when rendering.void
Enables or disables the invalidation of render caches.void
setLogicalViewportRegion
(SbViewportRegion newLogicalRegion) Sets current logical viewport region to use for rendering.void
setNumPasses
(int num) Sets number of rendering passes for multipass antialiasing.void
void
setPassCallback
(SoGLRenderPassCB func, Object userData) void
setPassUpdate
(boolean flag) Sets a flag indicating whether intermediate results are displayed after each antialiasing pass for progressive improvement (default is false).void
setRenderingIsRemote
(boolean flag) Sets whether or not "remote" rendering is done.void
setSmoothing
(boolean smooth) Deprecated.As of Open Inventor 101.0.0.0.void
setSortedLayersNumPasses
(int num) Sets the number of rendering passes used when transparency type isSORTED_PIXEL
.void
Sets global transparency algorithm to use when rendering.void
setUpdateArea
(SbVec2f origin, SbVec2f size) Sets the current update area, which is the rectangular area of the viewport region that will actually be rendered into.void
setViewportRegion
(SbViewportRegion newRegion) Changes viewport region to use for rendering.void
Called by nodes to say that they should/shouldn't be auto-cached (pass true if should, false if shouldn't, don't call this method at all if the node doesn't care):Methods inherited from class com.openinventor.inventor.actions.SoAction
apply, apply, clearApplyResult, forwardTraversal, forwardTraversal, getContinueActionInBranchFlag, getCurPath, getDistribMode, getNodeAppliedTo, getOriginalPathListAppliedTo, getPathAppliedTo, getPathCode, getPathListAppliedTo, getPipeId, getSceneManager, getState, getWhatAppliedTo, hasTerminated, invalidateState, isBeingApplied, isLastPathListAppliedTo, isUsingAlternateRep, nullAction, postDelayedTraversal, preDelayedTraversal, resetContinueActionInBranchFlag, setPipeId, setSceneManager, setUpState, stopActionInBranch, traverse, useAlternateRep
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
Constructor Details
-
SoGLRenderAction
Constructor. The parameter defines the viewport region into which rendering will take place.
-
-
Method Details
-
setPassCallback
-
setPassCallback
-
isSortedLayersSupported
public static boolean isSortedLayersSupported()Calls isSortedLayersSupported((com.openinventor.inventor.misc.SoState)null). -
setDecimationValue
Calls setDecimationValue(type, (float)1.0). -
handleTransparency
public boolean handleTransparency()Calls handleTransparency(false, false). -
setFastEditSavePolicy
Calls setFastEditSavePolicy(policy, false). -
resetFrameCounter
public void resetFrameCounter()Calls resetFrameCounter((int)0). -
handleTransparency
public boolean handleTransparency(boolean isTransparent) Calls handleTransparency(isTransparent, false). -
getUpdateArea
Returns the current update area. SeesetUpdateArea()
for details. -
setTransparencyType
Sets global transparency algorithm to use when rendering. . The default is NO_SORT, but SORTED_PIXEL is recommended for most cases. See alsogetTransparencyType()
. Transparency handling can be completely disabled by setting NO_SORT.The global transparency algorithm can also be set using a method in the viewer class (e.g. SoWinRenderArea.setTransparencyType()).
The default value for this field can be set using the environment variable OIV_TRANSPARENCY_TYPE.
See
SoGLRenderAction.TransparencyType
for more discussion about transparency.Notes:
- When using transparency types with DELAYED in the name, the depth buffer is not updated (depth buffer writes are disabled) while rendering transparent objects. As a result complex 3D shapes may not be rendered correctly.
- When using a delayed transparency mode, paths to transparent objects are saved in a list. After all opaque objects have been rendered, this list is rendered. In order to avoid unnecessary rendering, the common part of each path is rendered only once. This can increase performance on very complex scene graphs. However, in some cases, it can lead to incorrect rendering. In the figure below, node B is a transparent object and node A has a side effect on node B (clipping, shader...). When the compact path optimization is on (the default), node A will not be traversed during the transparency pass, which will lead to incorrect rendering. When a case like this occurs in your scene graph, set the environment variable OIV_USE_COMPACT_PATHS to false to disable this optimization.
-
getTransparencyType
Returns transparency quality level to use when rendering. SeesetTransparencyType()
. -
setFastEditSavePolicy
public void setFastEditSavePolicy(SoGLRenderAction.FastEditSavePolicies policy, boolean fastEditDelayedObjects) Sets fast editing save policy to use when rendering. The default is WHEN_NEEDED. Valid values are DISABLE, EACH_FRAME, and WHEN_NEEDED. SeeSoSeparator
.If fastEditDelayedObjects is set to true, delayed objects won't be redrawn when editing the scene graph. It means that the composition between delayed transparent objects and the fast edit scene graph won't be correct, but rendering will be much faster if there are a lot of transparent objects.
-
getRenderingIsRemote
public boolean getRenderingIsRemote()Returns true if remote rendering is being done. -
isUsedCacheContext
public static boolean isUsedCacheContext(int context) Returns true if the specified cache context id is currently used by anySoGLRenderAction
. -
shouldAutoCache
Called by nodes to say that they should/shouldn't be auto-cached (pass true if should, false if shouldn't, don't call this method at all if the node doesn't care): -
generateCacheContext
public static int generateCacheContext()Generates and returns a new cache context id. The returned cache context id can then be used to pass to thesetCacheContext()
method call. -
getFrameCounter
public int getFrameCounter()Returns the current frame counter. The frame counter starts at zero and is automatically incremented each time the action is applied. The frame counter will have the same value throughout a single apply, even if there are multiple render passes, delayed rendering, etc. -
getDecimationType
Gets decimation type. -
resetFrameCounter
public void resetFrameCounter(int count) Reset the frame counter. Do not call this method during a traversal. -
setInvalidateCacheMode
Enables or disables the invalidation of render caches.- When set to ALWAYS, the caches are invalidated for each
SoSeparator
node before its children are traversed. No new caches will be built. This value forces all nodes to be visited during each render traversal. - When set to ONCE, the caches are invalidated for each
SoSeparator
node before its children are traversed. The invalidate cache mode is automatically changed to OFF at the end of the traversal. - When set to OFF (default), caches are managed by their respective render caching nodes in the usual way.
This method is useful to force all nodes to be visited during render traversal.
- When set to ALWAYS, the caches are invalidated for each
-
getInvalidateCacheMode
Returns the current cache invalidation mode. -
getDecimationPercentage
public float getDecimationPercentage()Gets decimation percentage, the value should be a number between 0.0 and 1.0. -
setDecimationValue
Sets decimation percentage, the value should be a number between 0.0 and 1.0 Useful for reducing the number of triangles rendered in the scene. -
setLogicalViewportRegion
Sets current logical viewport region to use for rendering. Setting an empty viewport region (0,0) unsets the logical viewport. -
getLogicalViewportRegion
Returns current logical viewport region. -
setUpdateArea
Sets the current update area, which is the rectangular area of the viewport region that will actually be rendered into. This can be used for partial updates in applications that can manage them. The update area is specified in normalized viewport coordinates, where (0,0) is the lower left corner of the viewport and (1,1) is the upper right corner. The area is specified or returned as an origin and a size. -
setViewportRegion
Changes viewport region to use for rendering. -
getViewportRegion
Returns viewport region to use for rendering. -
handleTransparency
public boolean handleTransparency(boolean isTransparent, boolean isLinesOrPoints) -
getNumPasses
public int getNumPasses()Gets number of rendering passes for multipass rendering. -
setDelayedObjDepthWrite
public void setDelayedObjDepthWrite(boolean flag) Control whether delayed transparent objects update the depth buffer. By default they do not (historical behavior) -
isPassUpdate
public boolean isPassUpdate()Returns a flag indicating whether intermediate results are displayed after each antialiasing pass for progressive improvement. The default value can be set using the environment variable OIV_ANTIALIAS_PASS_UPDATE. -
abortNow
public boolean abortNow() -
setPassUpdate
public void setPassUpdate(boolean flag) Sets a flag indicating whether intermediate results are displayed after each antialiasing pass for progressive improvement (default is false). -
setNumPasses
public void setNumPasses(int num) Sets number of rendering passes for multipass antialiasing. The default is 1. Specifying more than one pass will result in antialiasing of the rendered scene, using OpenGL's accumulation buffer. (Camera nodes typically move their viewpoints a little bit for each pass to achieve the antialiasing.) Each additional pass provides better antialiasing, but requires more rendering time.The default value can be set using the environment variable OIV_NUM_RENDER_PASSES.
NOTE: Multipass antialiasing can have very poor performance for large scenes. Full-scene antialiasing (multi-sample) is strongly recommended when the hardware supports it. See
SoSceneManager
andSoFullSceneAntialiasing
. -
setSmoothing
Deprecated.As of Open Inventor 101.0.0.0. No longer used.Sets smoothing flag. When on, smoothing uses OpenGL's line- and point-smoothing features to provide cheap antialiasing of lines and points. The default is false.The default value can be set using the environment variable OIV_GL_SMOOTHING (0 = false, 1 = true).
Warning Deprecated since Open Inventor 101000. No longer used.
-
getCache
Returns the cache that has been set withsetCache()
-
getFastEditSavePolicy
Returns fast editing save policy used when rendering. -
getDelayedObjDepthWrite
public boolean getDelayedObjDepthWrite()Returns whether delayed transparent objects update the depth buffer. By default they do not (historical behavior) -
isSmoothing
Deprecated.As of Open Inventor 101.0.0.0. No longer used.Returns smoothing flag.Warning Deprecated since Open Inventor 101000. No longer used.
-
setCache
Sets the main cache to use with this render action. When calling apply() on this action, theSoCacheElement
will be set with this cache. -
setAlphaTest
public void setAlphaTest(boolean flag) Enable or disable the OpenGL alpha test for rendering. Default is false (alpha test disabled) and the default test is "not equal to zero". The alpha test operates on all pixel writes, including those resulting from the scan conversion of points, lines, polygons, and bitmaps, and from pixel draw and copy operations. It does not affect screen clear operations.For example, if rendering with textures containing "binary" alpha values (0 or 1), the alpha test may be faster than blended transparency and does not require the use of delayed rendering transparency types.
The default value can be set using the environment variable OIV_ALPHA_TEST (0 = false, 1 = true).
-
enableElement
-
getSortedLayersNumPasses
public int getSortedLayersNumPasses()Returns the number of rendering passes used when transparency type isSORTED_PIXEL
. -
setRenderingIsRemote
public void setRenderingIsRemote(boolean flag) Sets whether or not "remote" rendering is done. Inventor's auto-render-caching algorithm will choose to cache more often when rendering is remote (the assumption being that performance will be better with display lists stored on the remote machine). By default, it is assumed rendering is NOT remote. -
isSortedLayersSupported
Indicates ifSORTED_PIXEL
transparency is supported by your graphics board on the current context. -
isAlphaTest
public boolean isAlphaTest()Returns whether the OpenGL alpha test is enabled for rendering. -
isDoingDepthPeeling
public boolean isDoingDepthPeeling()Return true if depth peeling is active. -
enableDepthPeeling3D
public void enableDepthPeeling3D(boolean flag) Use 3D texturing instead of 2D for the fixed functionality emulation in depth peeling. -
setCacheContext
public void setCacheContext(int context) Sets the OpenGL cache context. A cache context is just an integer identifying when OpenGL display lists (which are used for render caching) can be shared between render actions; for example, see the documentation on GLX contexts for information on when OpenGL display lists can be shared between GLX windows. SeegenerateCacheContext()
. Note: The value 0xFFFFFFFF (~0) is reserved to represent an undefined id. -
getCurPass
public int getCurPass() -
setSortedLayersNumPasses
public void setSortedLayersNumPasses(int num) Sets the number of rendering passes used when transparency type isSORTED_PIXEL
. Default is 4.Note: Since Open Inventor 9.4, if the hardware supports the necessary OpenGL features, these transparency modes are implemented using a single-pass, order-independent fragment sorting (A-buffer) algorithm. Therefore the value of this field is not used except in two special cases:
- If hardware support for single pass transparency is not available, then the previous "depth peeling" algorithm is used (which normally requires multiple passes), or
- If volume rendering (see
SoVolumeRender
) is combined with geometry rendering, then multiple layers of transparency information are required and this field specifies the number of layers.
Use more passes for more correct transparency. Usually four passes (which is the default value) gives good results. For example, the number of passes needed for rendering an opaque sphere behind two cubes is the number of planes separating the sphere from the viewer. So, when backface culling is enabled, 2 faces separate the sphere from the viewer: the front face of the first cube and the front face of the second cube. The number of passes needed in this case is 2.
The default value for this field can be set using the environment variable OIV_NUM_SORTED_LAYERS_PASSES.
-
getDepthPeelingPass
public int getDepthPeelingPass()Get the current pass of depth peeling, -1 if not doing depth peeling. -
getCacheContext
public int getCacheContext()Returns the OpenGL cache context id for this action.
-