- All Implemented Interfaces:
public class SoVertexAttribFeedback extends SoSeparatorNode 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
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.
SoGpuBufferObjectcan 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.
disableFragmentProcessing true autoResizeBuffers false queryGeneratedPrimitivesCount false buffersMode SEPARATE primitiveType TRIANGLES
Do the actual vertex attributes feedback operation.
Nested Class Summary
Nested Classes Modifier and Type Class Description
SoVertexAttribFeedback.BufferModesThis enum is used by the field buffersMode to describe the data packing format in the buffer objects.
SoVertexAttribFeedback.PrimitiveTypesThis enum is used to setup the expected recorded primitive type from the shaders.
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
Fields Modifier and Type Field Description
autoResizeBuffersSet this field to true when the size of the recorded varyings is not known.
buffersModeThe buffer mode used to record the primitives.
disableFragmentProcessingTurn off the fragment rasterizer.
primitiveTypeThe type of primitive recorded during traversal.
queryGeneratedPrimitivesCountRead back the number of recorded primitives.
Fields inherited from class com.openinventor.inventor.nodes.SoSeparator
boundingBoxCaching, fastEditing, pickCulling, renderCaching, renderCulling, renderUnitId
Constructors Constructor Description
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description
getGeneratedPrimitivesCount()This function returns the number of generated primitives during the traversal of the sub scene graph.
isSupported(SoState state)This function indicates if the vertex attributes feedback feature is available on this system.
registerFeedback(java.lang.String varyingName, SoBufferObject bufferObject)Calls registerFeedback(varyingName, bufferObject, (int)-1).
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.
unregisterFeedback(java.lang.String varyingName)This function is used to unregister a varying registered with the registerFeedback function.
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
public final SoSFBool disableFragmentProcessingTurn 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.
public final SoSFBool autoResizeBuffersSet 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.
public final SoSFBool queryGeneratedPrimitivesCountRead 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.
public final SoSFEnum<SoVertexAttribFeedback.BufferModes> buffersModeThe buffer mode used to record the primitives. . Default is SEPARATE.
public void registerFeedback(java.lang.String varyingName, SoBufferObject bufferObject)Calls registerFeedback(varyingName, bufferObject, (int)-1).
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.
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.
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
SoGLExtensionfor an example of using
SoGLContextto avoid them.
- true if vertex attributes feedback is supported.
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.