Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoRenderToTarget Class Reference

VSG extension Group node that renders its children to one or more "targets". More...

#include <Inventor/nodes/SoRenderToTarget.h>

+ Inheritance diagram for SoRenderToTarget:

Public Types

enum  Attachment {
  COLOR0 ,
  COLOR1 ,
  COLOR2 ,
  COLOR3 ,
  COLOR4 ,
  COLOR5 ,
  COLOR6 ,
  COLOR7 ,
  COLOR8 ,
  COLOR9 ,
  COLOR10 ,
  COLOR11 ,
  COLOR12 ,
  COLOR13 ,
  COLOR14 ,
  COLOR15 ,
  DEPTH ,
  STENCIL ,
  DEPTH_STENCIL ,
  LAST_ENTRY
}
 Attachment. More...
 
enum  Mode {
  AUTO ,
  INTERNAL ,
  TARGET_COPY ,
  NONE
}
 This enum defines modifiers for the auto detection mechanism. More...
 
- Public Types inherited from SoSeparator
enum  CacheEnabled {
  OFF ,
  ON ,
  AUTO
}
 Possible values for caching. More...
 
enum  FastEditing {
  DISABLE = 0x01 ,
  KEEP_ZBUFFER = 0x02 ,
  CLEAR_ZBUFFER = 0x03
}
 Fast editing policy enumeration values. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoRenderToTarget ()
 Default constructor.
 
int getRasterizedSamplesCount () const
 Returns the number of samples generated by the rasterizer during the last GLRender action.
 
- Public Member Functions inherited from SoSeparator
 SoSeparator ()
 Creates a separator node with default settings.
 
 SoSeparator (int nChildren)
 Constructor that takes approximate number of children.
 
- Public Member Functions inherited from SoGroup
 SoGroup ()
 Creates an empty group node.
 
 SoGroup (int nChildren)
 Constructor that takes approximate number of children.
 
virtual void addChild (SoNode *child)
 Adds a child as last one in group.
 
virtual void insertChild (SoNode *child, int newChildIndex)
 Adds a child so that it becomes the one with the given index.
 
virtual SoNodegetChild (int index) const
 Returns pointer the child node with the given index.
 
virtual int findChild (const SoNode *child) const
 Finds index of given child within group.
 
virtual int getNumChildren () const
 Returns number of children.
 
virtual void removeChild (int index)
 Removes child with given index from group.
 
virtual void removeChild (SoNode *child)
 Removes first instance of given child from group.
 
virtual void removeAllChildren ()
 Removes all children from group.
 
virtual void replaceChild (int index, SoNode *newChild)
 Replaces child with given index with new child.
 
virtual void replaceChild (SoNode *oldChild, SoNode *newChild)
 Replaces first instance of given child with new child.
 
- Public Member Functions inherited from SoNode
virtual void setOverride (const SbBool state)
 Turns the override flag on or off.
 
virtual SbBool isOverride () const
 Returns the state of the override flag.
 
virtual SoNodecopy (SbBool copyConnections=FALSE) const
 Creates and returns an exact copy of the node.
 
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
SbBool set (const SbString &fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SbBool isSupported (SoState *state=NULL)
 Indicates if this node can be used on the actual hardware.
 
- Static Public Member Functions inherited from SoSeparator
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoGroup
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoNode
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNodegetByName (const SbName &name)
 A node's name can be set using SoBase::setName().
 
static int getByName (const SbName &name, SoNodeList &list)
 A node's name can be set using SoBase::setName().
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Public Attributes

SoMFEnum modes
 This defines the mode modifier for the targets.
 
SoMFNode targets
 This field allows to attach a texture to a specific attachment.
 
SoMFInt32 layers
 This field is used when targets are SoTexture3 or SoTextureCubeMap.
 
SoSFBool clearTargets
 If this field is set the targets are cleared before 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.
 
SoSFFloat antialiasingQuality
 This field defines the antialiasing quality between 0.0 and 1.0 for the rendering.
 
SoSFVec2i32 size
 This field allows a custom rendering size for the render to texture.
 
SoSFBool enableFragmentsQuery
 This field enables or disables the query counter used to count the number of fragments rasterized during the render to texture operation.
 
- Public Attributes inherited from SoSeparator
SoSFEnum boundingBoxCaching
 Whether to cache during bounding box traversal.
 
SoSFEnum renderCulling
 Whether to cull during rendering traversal.
 
SoSFEnum pickCulling
 Whether to cull during picking traversal.
 
SoSFEnum fastEditing
 Specifies the fast edit mode of the separator node.
 
SoSFInt32 renderUnitId
 Used during the ScaleViz depth compositing process, this field specifies which render unit (OIRU) will render the sub scene graph below this separator.
 
SoDEPRECATED SoSFEnum renderCaching
 Whether to cache during rendering traversal.
 
- Public Attributes inherited from SoGroup
SoSFBool boundingBoxIgnoring
 Whether to ignore this node during bounding box traversal.
 

Detailed Description

VSG extension 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 and clearStencilValue. It is also possible to disable this feature by setting the field clearTargets 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.
  • Target limitations:
  • 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 an SoSeparator 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 an SoGLRenderAction. In this case the children of the SoRenderToTarget will normally include a camera, light, etc node. But also note that, in this case, the OpenGL calls normally made by the viewer and/or SoSceneManager will not be done automatically. For example, the OpenGL depth test is not enabled. Use an SoDepthBuffer node to do this.
  • Bounding box
    • WARNING: The 'boundingBoxIgnoring' default value is TRUE.
      Usually the SoRenderToTarget 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 the SoRenderToTarget scenegraph's bounding box, like when doing post-processing effects. In that case, manually set 'boundingBoxIgnoring' to FALSE.
  • 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.

NOTE: node available 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

SEE ALSO

SoTexture, SoTexture2.

Definition at line 143 of file SoRenderToTarget.h.

Member Enumeration Documentation

◆ Attachment

Attachment.

This enum is used to specify which output of the rasterizer is considered. Use these values as indices when setting the targets and modes fields.

Enumerator
COLOR0 

Default attachment used for rendering.

COLOR1 
COLOR2 
COLOR3 
COLOR4 
COLOR5 
COLOR6 
COLOR7 
COLOR8 
COLOR9 
COLOR10 
COLOR11 
COLOR12 
COLOR13 
COLOR14 
COLOR15 
DEPTH 
STENCIL 
DEPTH_STENCIL 
LAST_ENTRY 

Not used, for security only.

Definition at line 155 of file SoRenderToTarget.h.

◆ Mode

This enum defines modifiers for the auto detection mechanism.

Enumerator
AUTO 

Default value, use OIV auto detection algorithm.

The detection algorithm checks the content of the targets field. NOTE: The node will use INTERNAL for DEPTH and COLOR0, NONE for the others.

INTERNAL 

Use an internal buffer for the rendering.

Some buffers are useful only for shaders or for correct rendering (like depth buffer for the depth tests) but they don't need to be attached to a specific target.

TARGET_COPY 

After the rendering the rendered content is copied back to the node in CPU memory.

NONE 

Do not use any target.

Definition at line 184 of file SoRenderToTarget.h.

Constructor & Destructor Documentation

◆ SoRenderToTarget()

SoRenderToTarget::SoRenderToTarget ( )

Default constructor.

Member Function Documentation

◆ getClassTypeId()

static SoType SoRenderToTarget::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getRasterizedSamplesCount()

int SoRenderToTarget::getRasterizedSamplesCount ( ) const

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.

◆ getTypeId()

virtual SoType SoRenderToTarget::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoSeparator.

◆ isSupported()

static SbBool SoRenderToTarget::isSupported ( SoState state = NULL)
static

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 see SoGLExtension for an example of using SoGLContext to avoid them.

Member Data Documentation

◆ antialiasingQuality

SoSFFloat SoRenderToTarget::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.

Definition at line 302 of file SoRenderToTarget.h.

◆ clearColorValue

SoSFVec4f SoRenderToTarget::clearColorValue

Value used to clear the color buffer before the rendering.

Default is (0.0, 0.0, 0.0, 0.0).

Definition at line 282 of file SoRenderToTarget.h.

◆ clearDepthValue

SoSFFloat SoRenderToTarget::clearDepthValue

Value used to clear the depth buffer before the rendering.

Default is 1.0.

Definition at line 287 of file SoRenderToTarget.h.

◆ clearStencilValue

SoSFInt32 SoRenderToTarget::clearStencilValue

Value used to clear the stencil buffer before the rendering.

Default is 0.

Definition at line 292 of file SoRenderToTarget.h.

◆ clearTargets

SoSFBool SoRenderToTarget::clearTargets

If this field is set the targets are cleared before the rendering.

Default is TRUE.

Definition at line 277 of file SoRenderToTarget.h.

◆ enableFragmentsQuery

SoSFBool SoRenderToTarget::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.

Definition at line 317 of file SoRenderToTarget.h.

◆ layers

SoMFInt32 SoRenderToTarget::layers

This field is used when targets are SoTexture3 or SoTextureCubeMap.

It describes the layer where the color attachment must be written, along the Z dimension for SoTexture3, or the cube map face for SoTextureCubeMap (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 type SoTexture2 or when target attachments are DEPTH or STENCIL, which require a SoTexture2 Target.

Layer number Cube Map Face
0 Positive X
1 Negative X
2 Positive Y
3 Negative Y
4 Positive Z
5 Negative Z

Definition at line 272 of file SoRenderToTarget.h.

◆ modes

SoMFEnum SoRenderToTarget::modes

This defines the mode modifier for the targets.

For each target it is possible to specify a mode. Use enum Mode. 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;

Definition at line 218 of file SoRenderToTarget.h.

◆ size

SoSFVec2i32 SoRenderToTarget::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.

Definition at line 309 of file SoRenderToTarget.h.

◆ targets

SoMFNode SoRenderToTarget::targets

This field allows to attach a texture to a specific attachment.

Supported target types are SoTexture2, SoTexture3 and SoTextureCubeMap. 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;

Definition at line 230 of file SoRenderToTarget.h.


The documentation for this class was generated from the following file: