HdStInstancer Class Reference

HdSt implements instancing by drawing each proto multiple times with a single draw call. More...

+ Inheritance diagram for HdStInstancer:

Public Member Functions

HDST_API HdStInstancer (HdSceneDelegate *delegate, SdfPath const &id)
 Constructor. More...
 
HDST_API void Sync (HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
 
HdBufferArrayRangeSharedPtr GetInstancePrimvarRange () const
 
HDST_API VtIntArray GetInstanceIndices (SdfPath const &prototypeId)
 Populates the instance index indirection buffer for prototypeId and returns a flat array of instance index tuples. More...
 
- Public Member Functions inherited from HdInstancer
HD_API HdInstancer (HdSceneDelegate *delegate, SdfPath const &id)
 Constructor. More...
 
SdfPath const & GetId () const
 Returns the identifier. More...
 
SdfPath const & GetParentId () const
 Returns the parent instancer identifier. More...
 
HdSceneDelegateGetDelegate () const
 
virtual HD_API void Finalize (HdRenderParam *renderParam)
 
virtual HD_API HdDirtyBits GetInitialDirtyBitsMask () const
 

Protected Member Functions

HDST_API void _GetInstanceIndices (SdfPath const &prototypeId, std::vector< VtIntArray > *instanceIndicesArray)
 
HDST_API void _SyncPrimvars (HdSceneDelegate *sceneDelegate, HdDirtyBits *dirtyBits)
 
- Protected Member Functions inherited from HdInstancer
HD_API void _UpdateInstancer (HdSceneDelegate *delegate, HdDirtyBits *dirtyBits)
 

Additional Inherited Members

- Static Public Member Functions inherited from HdInstancer
static HD_API int GetInstancerNumLevels (HdRenderIndex &index, HdRprim const &rprim)
 
static HD_API TfTokenVector const & GetBuiltinPrimvarNames ()
 
static HD_API void _SyncInstancerAndParents (HdRenderIndex &renderIndex, SdfPath const &instancerId)
 

Detailed Description

HdSt implements instancing by drawing each proto multiple times with a single draw call.

Application of instance primvars (like transforms) is done in shaders. Instance transforms in particular are computed in ApplyInstanceTransform in instancing.glslfx.

If this instancer is nested, instance indices will be computed recursively by ascending the hierarchy. HdStInstancer computes a flattened index structure for each prototype by taking the cartesian product of the instance indices at each level.

For example:

  • InstancerA draws instances [ProtoX, InstancerB, ProtoX, InstancerB]
  • InstancerB draws instances [ProtoY, ProtoZ, ProtoY] The flattened index for Proto Y is: [0, 0, 1]; [1, 0, 3]; [2, 2, 1]; [3, 2, 3]; where the first tuple element is the position in the flattened index; the second tuple element is the position in Instancer B; and the last tuple element is the position in Instancer A.

The flattened index gives the number of times the proto is drawn, and the index tuple can be passed to the shader so that each instance can look up its instance primvars in the bound primvar arrays.

Definition at line 68 of file instancer.h.

Constructor & Destructor Documentation

◆ HdStInstancer()

HDST_API HdStInstancer ( HdSceneDelegate delegate,
SdfPath const &  id 
)

Constructor.

Member Function Documentation

◆ GetInstanceIndices()

HDST_API VtIntArray GetInstanceIndices ( SdfPath const &  prototypeId)

Populates the instance index indirection buffer for prototypeId and returns a flat array of instance index tuples.


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