Class SoRenderToTarget
- java.lang.Object
-
- All Implemented Interfaces:
SafeDisposable
public class SoRenderToTarget extends SoSeparator
Group node that renders its children to one or more "targets". This group node renders its children to one or more render targets.Multiple targets can be "attached" to the different outputs of the node.
This node also provides antialiasing. When FrameBufferObjects (FBO) are used (this is the default mode if they are available) multisampling can be configured in order to perform antialiasing on the FBO. This MSAA feature is not related to the viewer's FSAA. The quality factor is set between 0.f(default value) and 1.f. The underlying system will setup the FBO with the correct number of samples according to the quality value and according to the attachments configuration.
By default the node clears the targets when the rendering is started. The values used to clear the buffers can be specified by the fields
clearColorValue
,clearDepthValue
andclearStencilValue
. It is also possible to disable this feature by setting the fieldclearTargets
to false.During rendering, the viewport from the Open Inventor state is used, which means that the current size of the render area is used. It is possible to change this default behavior by setting the
size
field. Setting it to (-1, -1) will switch back to the default mode, other values will be used as the custom rendering size in pixels. The targets are automatically resized to the correct size.The
SoRenderToTextureProperty
node can also be used to create a texture image and is useful for simpler cases.NOTES:
- Performance:
- Using the TARGET_COPY mode at each frame really reduces performance because a transfer from GPU memory to CPU memory is performed to transfer the data to the
SoSFImage
field of the texture. - Antialiasing (MSAA) can really reduce performance and increase memory consumption. It can even be impossible to use antialiasing with large FLOAT color attachments.
- Using the TARGET_COPY mode at each frame really reduces performance because a transfer from GPU memory to CPU memory is performed to transfer the data to the
- Target limitations:
- Only
SoTexture2
,SoTexture3
andSoTextureCubeMap
nodes are supported. Using other types in the targets field will result in SoDebugErrors.
- Only
- By default the textures are resized using the following rules:
- RBGA uint8 for the color attachements. (Internal mode is RGBA8)
- Luminance float32 for the depth attachment. (Internal mode is DEPTH_COMPONENT24).
- Luminance uint8 for the stencil attachment. It is possible to override the default internal mode for the textures by using the internalFormat field of
SoTexture
.
- Rendering
SoRenderToTarget
is anSoSeparator
and can be added directly to the scene graph. In this case its children are rendered as part of the main scene graph and inherit properties (camera, light, material, etc) from the main scene graph.
SoRenderToTarget
can also be used separate from the main scene graph and re-rendered as-needed by applying anSoGLRenderAction
. In this case the children of theSoRenderToTarget
will normally include a camera, light, etc node. But also note that, in this case, the OpenGL calls normally made by the viewer and/orSoSceneManager
will not be done automatically. For example, the OpenGL depth test is not enabled. Use anSoDepthBuffer
node to do this.
- Bounding box
- WARNING: The 'boundingBoxIgnoring' default value is true.
Usually theSoRenderToTarget
scenegraph is not really part of the main scene and should not have any effect on the bounding box computed for the main scene. For this reason, SORTED_OBJECT_BLEND transparency is not supported for shapes that are children of this node. But in some cases, it can be useful to include theSoRenderToTarget
scenegraph's bounding box, like when doing post-processing effects. In that case, manually set 'boundingBoxIgnoring' to false.
- WARNING: The 'boundingBoxIgnoring' default value is true.
- Hardware compatibility:
- All the exposed features are supported by the FBO rendering subsystem. PBuffer and pixmap might not support some of them. For example it is not possible to have multiple color attachments in PBuffer mode. Those alternative modes are supported only for compatibility with legacy hardware.
- Since:
- Open Inventor 8.6
File format/default:
RenderToTarget {
modes AUTO targets NULL layers 0 clearTargets true clearColorValue (0.F, 0.F, 0.F, 0.F) clearDepthValue 1.F clearStencilValue 0 antialiasingQuality 0.F size (-1, -1) enableFragmentsQuery false Action behavior:
SoGLRenderAction
Performs an offscreen rendering using either FBO, PBuffer or pixmap. Sets:SoCacheElement
- See Also:
SoTexture
,SoTexture2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SoRenderToTarget.Attachments
Attachment.static class
SoRenderToTarget.ModeType
This enum defines modifiers for the auto detection mechanism.-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoSeparator
SoSeparator.Cachings, SoSeparator.FastEditings, SoSeparator.RenderUnitIds
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
Fields Modifier and Type Field Description SoSFFloat
antialiasingQuality
This field defines the antialiasing quality between 0.0 and 1.0 for the rendering.SoSFVec4f
clearColorValue
Value used to clear the color buffer before the rendering.SoSFFloat
clearDepthValue
Value used to clear the depth buffer before the rendering.SoSFInt32
clearStencilValue
Value used to clear the stencil buffer before the rendering.SoSFBool
clearTargets
If this field is set the targets are cleared before the rendering.SoSFBool
enableFragmentsQuery
This field enables or disables the query counter used to count the number of fragments rasterized during the render to texture operation.SoMFInt32
layers
This field is used when targets areSoTexture3
orSoTextureCubeMap
.SoMFEnum<SoRenderToTarget.ModeType>
modes
This defines the mode modifier for the targets.SoSFVec2i32
size
This field allows a custom rendering size for the render to texture.SoMFNode
targets
This field allows to attach a texture to a specific attachment.-
Fields inherited from class com.openinventor.inventor.nodes.SoSeparator
boundingBoxCaching, fastEditing, pickCulling, renderCaching, renderCulling, renderUnitId
-
Fields inherited from class com.openinventor.inventor.nodes.SoGroup
boundingBoxIgnoring
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoRenderToTarget()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getRasterizedSamplesCount()
Returns the number of samples generated by the rasterizer during the last GLRender action.static boolean
isSupported()
Calls isSupported((com.openinventor.inventor.misc.SoState)null).static boolean
isSupported(SoState state)
Indicates if this node can be used on the actual hardware.-
Methods inherited from class com.openinventor.inventor.nodes.SoGroup
addChild, findChild, getChild, getNumChildren, insertChild, removeAllChildren, removeChild, removeChild, replaceChild, replaceChild
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Field Detail
-
modes
public final SoMFEnum<SoRenderToTarget.ModeType> modes
This defines the mode modifier for the targets. For each target it is possible to specify a mode. Use enumMode
. Default is AUTO.NOTE: This field is indexed using the Attachment enum. For example (in pseudo-code):
- modes[COLOR0] = TARGET_AND_COPY;
- modes[STENCIL] = INTERNAL;
-
targets
public final SoMFNode targets
This field allows to attach a texture to a specific attachment. Supported target types areSoTexture2
,SoTexture3
andSoTextureCubeMap
. Default is empty (no targets).NOTE: This field is indexed using the Attachment enum. For example (in pseudo-code):
- targets[COLOR0] = rgbaTexture;
- targets[STENCIL] = stencilTexture;
-
layers
public final SoMFInt32 layers
This field is used when targets areSoTexture3
orSoTextureCubeMap
. It describes the layer where the color attachment must be written, along the Z dimension forSoTexture3
, or the cube map face forSoTextureCubeMap
(the cube map faces order is presented in the table below). This field is indexed by color attachments (i.e. from COLOR0 to COLOR15) and has no effect when targets are of typeSoTexture2
or when target attachments are DEPTH or STENCIL, which require aSoTexture2
Target.Layer number Cube Map Face 0 Positive X 1 Negative X 2 Positive Y 3 Negative Y 4 Positive Z 5 Negative Z
-
clearTargets
public final SoSFBool clearTargets
If this field is set the targets are cleared before the rendering. Default is true.
-
clearColorValue
public final SoSFVec4f clearColorValue
Value used to clear the color buffer before the rendering. Default is (0.0, 0.0, 0.0, 0.0).
-
clearDepthValue
public final SoSFFloat clearDepthValue
Value used to clear the depth buffer before the rendering. Default is 1.0.
-
clearStencilValue
public final SoSFInt32 clearStencilValue
Value used to clear the stencil buffer before the rendering. Default is 0.
-
antialiasingQuality
public final SoSFFloat antialiasingQuality
This field defines the antialiasing quality between 0.0 and 1.0 for the rendering. The value 1.0 represents the maximun quality possible on this hardware. Default is 0.NOTE: Hardware limitations: The result depends on the support for multisampling in FBO or the FSAA support for PBuffers.
-
size
public final SoSFVec2i32 size
This field allows a custom rendering size for the render to texture. When this field is set to the default value (-1, -1) the global viewport size from the viewer is used. The size is in pixels.
-
enableFragmentsQuery
public final SoSFBool enableFragmentsQuery
This field enables or disables the query counter used to count the number of fragments rasterized during the render to texture operation. Default is false.The method
getRasterizedSamplesCount()
can be used to get the result of the query.
-
-
Method Detail
-
isSupported
public static boolean isSupported()
Calls isSupported((com.openinventor.inventor.misc.SoState)null).
-
getRasterizedSamplesCount
public int getRasterizedSamplesCount()
Returns the number of samples generated by the rasterizer during the last GLRender action. To enable this feature the enableFragmentsQuery field must be set to true. Otherwise the result is undefined.
-
isSupported
public static boolean isSupported(SoState state)
Indicates if this node can be used on the actual hardware. When using a debug build of Open Inventor, some "no context available" warning messages may be generated. You can ignore them or seeSoGLExtension
for an example of usingSoGLContext
to avoid them.
-
-