author | Florian Link |
package | MeVisLab/Standard |
dll | SoRenderers |
definition | SoRenderers.def |
keywords | multi, instances, array |
The SoDrawInstanced module can be used to render the same geometry thousands of times, each using different attributes.
The module supports the following attributes:
Please note that the module currently does not calculate the correct bounding box of the rendered instances. This is due to the performance implications.
You can add an invisible bounding geometry (e.g. a SoSphere with SoDrawStyle set to invisible) to the scene to ensure a large enough bounding box.
You can place most Open Inventor geometries below this module and they will be rendered Num Instances times.
To provide the per-instance attributes, place SoVertexAttribute3f, SoVertexAttributeRotation, SoVertexAttribute4ub or SoVertexAttribute4f modules into the scene. Make sure that you enable the "Per Instance" check box on each of these attributes.
Use the following name and type for the attributes:
type name ========================== ================================= SoVertexAttributeRotation instanceRotation SoVertexAttribute3f instanceScale SoVertexAttribute3f instanceTranslation SoVertexAttribute4ub/4f instanceColor
The transformations are applied in this order:
To make sure that rotation works well, your rendered geometry should be centered around (0,0,0) in object space. Normals are transformed using the inverse transposed of the scale/rotate/translate matrix, so that shading on the transformed instances works well.
The model-view matrix is applied after the per instance transformation.
The module supports the following Open Inventor geometries
The SoWEMRenderer and other modules that are base on the above modules will work as well.
If filling a SoVertexAttribute3f or SoVertexAttributeRotation is too slow or the string representation of the module gets too big, consider creating a C++ module, which instantiates a SoVertexAttribute* attribute internally and adds it to the scene.
Alternatively you can use the Python inventor bindings, to create SoVertexAttribute* nodes, fill them with NumPy and add them to a custom scene in a macro module.
This module makes use of the GLSL Shader Pipeline. It can be extended with additional per-instance vertex attributes and the shader can be modified/extended as well.
Auto Detect Num Instances: Bool | Object Center: Vector3 |
boundingBoxCaching: Enum | pickCulling: Enum |
Hardware Instancing Supported: Bool | renderCaching: Enum |
Instance Color: Bool | renderCulling: Enum |
Instance Rotation: Bool | Use Hardware Instancing: Bool |
Instance Scale: Bool | |
Instance Translation: Bool | |
Num Instances: Integer |
The number of instances that are drawn.
Auto-detects the number of instances from the per-instance vertex attributes that are provided.
Enables per-instance translation. Provide a SoVertexAttribute3f named instanceTranslation.
Enables per-instance rotation. Provide a SoVertexAttributeRotation named instanceRotation. The rotation is passed as a quaternion using vec4.
Enables per-instance scaling. Provide a SoVertexAttribute3f named instanceScale.
Enables per-instance colors. Provide a SoVertexAttribute4ub or SoVertexAttribute4f named instanceColor.
If enabled, glDrawArraysInstanced or glDrawElementsInstanced is used. If disabled, each instance is drawn using a glDrawArrays or glDrawElements call and the per-instance properties are passed to the shader using uniforms. This modules takes care to automatically transfer the data from the per-instance vertex attributes to the uniforms.