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, SdfPath const &parentInstancerId)
 Constructor. More...
 
HDST_API void UpdateInstancePrimvarRange (HdRprim *prim, HdStDrawItem *drawItem, int drawCoordIndex)
 Updates _instancePrimvarRange with the instance rate primvars. More...
 
HdBufferArrayRangeSharedPtr GetInstancePrimvarRange () const
 
HDST_API
HdBufferArrayRangeSharedPtr 
GetInstanceIndices (SdfPath const &prototypeId)
 
HDST_API void PopulateDrawItem (HdRprim *prim, HdStDrawItem *drawItem, HdRprimSharedData *sharedData, HdDirtyBits dirtyBits)
 
- Public Member Functions inherited from HdInstancer
HD_API HdInstancer (HdSceneDelegate *delegate, SdfPath const &id, SdfPath const &parentInstancerId)
 Constructor. More...
 
virtual ~HdInstancer ()
 
SdfPath constGetId () const
 Returns the identifier. More...
 
SdfPath constGetParentId () const
 Returns the parent instancer identifier. More...
 
HdSceneDelegateGetDelegate () const
 
HD_API TfTokenVector constGetBuiltinPrimvarNames () const
 

Protected Member Functions

HDST_API void _GetInstanceIndices (SdfPath const &prototypeId, std::vector< VtIntArray > *instanceIndicesArray)
 

Additional Inherited Members

- Static Public Member Functions inherited from HdInstancer
static HD_API int GetInstancerNumLevels (HdRenderIndex &index, HdRprim const &rprim)
 

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 70 of file instancer.h.

Constructor & Destructor Documentation

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

Constructor.

Member Function Documentation

HDST_API void HdStInstancer::_GetInstanceIndices ( SdfPath const prototypeId,
std::vector< VtIntArray > *  instanceIndicesArray 
)
protected
HDST_API HdBufferArrayRangeSharedPtr HdStInstancer::GetInstanceIndices ( SdfPath const prototypeId)

Populates the instance index indirection buffer for prototypeId and returns the buffer range.

HdBufferArrayRangeSharedPtr HdStInstancer::GetInstancePrimvarRange ( ) const
inline

Definition at line 83 of file instancer.h.

HDST_API void HdStInstancer::PopulateDrawItem ( HdRprim prim,
HdStDrawItem drawItem,
HdRprimSharedData sharedData,
HdDirtyBits  dirtyBits 
)

Populates the rprim's draw item with the appropriate instancer buffer range data.

HDST_API void HdStInstancer::UpdateInstancePrimvarRange ( HdRprim prim,
HdStDrawItem drawItem,
int  drawCoordIndex 
)

Updates _instancePrimvarRange with the instance rate primvars.


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