Class SoVertexAttribFeedback

  • All Implemented Interfaces:

    public class SoVertexAttribFeedback
    extends SoSeparator
    Node to record vertex attributes from shaders into buffer objects. This node is used to record selected vertex attributes for each primitive processed by the OpenGL system. The recorded vertex attributes may be stored in separate SoGpuBufferObjects or interleaved into a single buffer object.

    This node can only be used when an GLSL shader is enabled on the Open Inventor state. If the active shader contains a geometry shader the attributes are recorded from the varyings declared in it, otherwise it records the attributes from the vertex shader.

    The function registerFeedback is used to specify the buffer object, which will receive the data, attached to a specified varying.

    The scene graph which will be rendered during the traversal (can be any shape used as input of the geometry or vertex shader) is specified using the regular addChild function from the class SoSeparator.

    This node provides a mechanism for the following features:

    • Rasterizer can be disabled to prevent rendering the generated primitives. This is useful when the main behavior is to record computed primitives from the geometry or vertex shader.
    • The SoGpuBufferObject can be automatically resized to be able to record all the data.
    • The number of generated primitives can be retrieved after the traversal.


    • The automatic resize of the buffer objects requires two traversal of the children, one to compute the number of primitives which will be generated and the actual traversal.
    • Most of the regular actions (except Render and Write) don't traverse the children.

      File format/default:

      VertexAttribFeedback {

        disableFragmentProcessing true
        autoResizeBuffers false
        queryGeneratedPrimitivesCount false
        buffersMode SEPARATE
        primitiveType TRIANGLES

      Action behavior:

      Do the actual vertex attributes feedback operation.

    See Also:
    SoBufferObject, SoShaderProgram, SoBufferedShape
    • Field Detail

      • disableFragmentProcessing

        public final SoSFBool disableFragmentProcessing
        Turn off the fragment rasterizer. It means that the result of the shader is not rendered.

        Most of the time the main goal of this node is to record the result of varyings from the geometry shaders and the recorded primitives are not supposed to be rendered.

        Default value is true.

      • autoResizeBuffers

        public final SoSFBool autoResizeBuffers
        Set this field to true when the size of the recorded varyings is not known. It provides a mechanism to automatically resize the buffer objects.

        This is implemented by performing a first traversal of the children with OpenGL queries enabled to record the number of generated primitives during this traversal. Then the value of the query is used to compute the size in bytes of the buffer object and a second traversal is performed for the actual primitives recording.

        Default value is false.

      • queryGeneratedPrimitivesCount

        public final SoSFBool queryGeneratedPrimitivesCount
        Read back the number of recorded primitives. The read back is performed only when this field is set to true and the method getGeneratedPrimitivesCount returns the value.

        Default value is false.

    • Constructor Detail

      • SoVertexAttribFeedback

        public SoVertexAttribFeedback()
        Default constructor.
    • Method Detail

      • registerFeedback

        public void registerFeedback​(java.lang.String varyingName,
                                     SoBufferObject bufferObject)
        Calls registerFeedback(varyingName, bufferObject, (int)-1).
      • registerFeedback

        public void registerFeedback​(java.lang.String varyingName,
                                     SoBufferObject bufferObject,
                                     int primitiveSize)
        This function allows to attach a buffer object to a specific varying of the shader pushed on the state. When the buffersMode field is set to INTERLEAVED only the first specified bufferObject is used.

        The primitiveSize parameter is used to compute the actual size of buffer objects when autoResizeBuffers is set to true, it is ignored otherwise; It must be the size of each primitive, in bytes. When the buffer mode is set to INTERLEAVED the value must be the accumulated size in bytes for all the varyings. The actual buffer size is computed by multiplying the primitiveSize by the number of primitives and by the size of the data type (float). When the value is -1 (the default value) Open Inventor uses 3 * sizeof(float) * numVerticesPerPrimtive, which is the size of a basic triangle with 3 vertices of 3 float-components, for a triangle the computed value is 3 * sizeof(float) * 3.

        NOTE: When the buffer mode is set to INTERLEAVED only the first specified buffer object is used the following ones are ignored.

        varyingName - The name of the varying which must will be added to the list of recorded varyings.

        bufferObject - The buffer object which will receive the recorded values from the varying.

        primitiveSize - The size, in bytes, of one primitive, used when the autoResizeBuffers field is set to true.
      • unregisterFeedback

        public void unregisterFeedback​(java.lang.String varyingName)
        This function is used to unregister a varying registered with the registerFeedback function.

        varyingName - The name of the varying to unregister, previously registered using the registerFeeback function.
      • isSupported

        public static boolean isSupported​(SoState state)
        This function indicates if the vertex attributes feedback feature is available on this system. 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.

        true if vertex attributes feedback is supported.

      • getGeneratedPrimitivesCount

        public int getGeneratedPrimitivesCount()
        This function returns the number of generated primitives during the traversal of the sub scene graph. NOTE: The returned value is undefined if the field queryGeneratedPrimitivesCount is not set to true.

        The number of generated primitives.