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

This class implements the HdEmbreePrimvarSampler interface for primvars on triangle meshes with "face-varying" interpolation modes. More...

+ Inheritance diagram for HdEmbreeTriangleFaceVaryingSampler:

Public Member Functions

 HdEmbreeTriangleFaceVaryingSampler (TfToken const &name, VtValue const &value, HdMeshUtil &meshUtil)
 Constructor. More...
 
virtual bool Sample (unsigned int element, float u, float v, void *value, HdTupleType dataType) const
 Sample the primvar at an (element, u, v) location. More...
 
- Public Member Functions inherited from HdEmbreePrimvarSampler
 HdEmbreePrimvarSampler ()=default
 Default constructor. More...
 
virtual ~HdEmbreePrimvarSampler ()=default
 Default destructor. More...
 
template<typename T >
bool Sample (unsigned int element, float u, float v, T *value) const
 

Additional Inherited Members

- Static Protected Member Functions inherited from HdEmbreePrimvarSampler
static bool _Interpolate (void *out, void **samples, float *weights, size_t sampleCount, HdTupleType dataType)
 Utility function for derived classes: combine multiple samples with blend weights: out = sum_i { samples[i] * weights[i] }. More...
 

Detailed Description

This class implements the HdEmbreePrimvarSampler interface for primvars on triangle meshes with "face-varying" interpolation modes.

This means that each vertex of each face gets its own buffer item: vertex 0 as part of face 0 might have value 1.0f, but vertex 0 as part of face 1 might have value 2.0f. The primvar's memory layout is grouped by face, with one item per vertex.

Concretely, a cube with 8 vertices would have 24 items (6 faces * 4 vertices) in a face-varying primvar, and the index of the item for face 2, vertex 3, would be (2 * 4 + 3) = 11.

Face-varying primvars are provided to the sampler un-triangulated, but the size of the buffer is tied to the size of the topology, so this class triangulates the input buffer before sampling.

Definition at line 219 of file meshSamplers.h.

Constructor & Destructor Documentation

HdEmbreeTriangleFaceVaryingSampler ( TfToken const &  name,
VtValue const &  value,
HdMeshUtil meshUtil 
)
inline

Constructor.

Triangulates the provided buffer data.

Parameters
nameThe name of the primvar.
valueThe buffer data for the primvar.
meshUtilAn HdMeshUtil instance that knows how to triangulate the input buffer data.

Definition at line 226 of file meshSamplers.h.

Member Function Documentation

virtual bool Sample ( unsigned int  element,
float  u,
float  v,
void *  value,
HdTupleType  dataType 
) const
virtual

Sample the primvar at an (element, u, v) location.

For face varying primvars, the vertex indices are simply (element * 3 + 0->2), since all faces are triangles. After fetching the primvar value for each of the three vertices, they are interpolated as follows, per Embree specification: t_uv = (1-u-v)*t0 + u*t1 + v*t2

Parameters
elementThe element index to sample.
uThe u coordinate to sample.
vThe v coordinate to sample.
valueThe memory to write the value to (only written on success).
dataTypeThe HdTupleType describing element values.
Returns
True if the value was successfully sampled.

Implements HdEmbreePrimvarSampler.


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