HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdStInstancer Class Reference

#include <instancer.h>

+ 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)
 
- Public Member Functions inherited from HdInstancer
HD_API HdInstancer (HdSceneDelegate *delegate, SdfPath const &id)
 Constructor. More...
 
virtual HD_API ~HdInstancer ()
 
SdfPath constGetId () const
 Returns the identifier. More...
 
SdfPath constGetParentId () 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 constGetBuiltinPrimvarNames ()
 
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

HDST_API HdStInstancer::HdStInstancer ( HdSceneDelegate delegate,
SdfPath const id 
)

Constructor.

Member Function Documentation

HDST_API void HdStInstancer::_GetInstanceIndices ( SdfPath const prototypeId,
std::vector< VtIntArray > *  instanceIndicesArray 
)
protected
HDST_API void HdStInstancer::_SyncPrimvars ( HdSceneDelegate sceneDelegate,
HdDirtyBits dirtyBits 
)
protected
HDST_API VtIntArray HdStInstancer::GetInstanceIndices ( SdfPath const prototypeId)

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

HdBufferArrayRangeSharedPtr HdStInstancer::GetInstancePrimvarRange ( ) const
inline

Definition at line 82 of file instancer.h.

HDST_API void HdStInstancer::Sync ( HdSceneDelegate sceneDelegate,
HdRenderParam renderParam,
HdDirtyBits dirtyBits 
)
overridevirtual

Reimplemented from HdInstancer.


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