This class implements the HdEmbreePrimvarSampler interface for primvars on triangle meshes with "face-varying" interpolation modes. More...
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... | |
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.
|
inline |
Constructor.
Triangulates the provided buffer data.
name | The name of the primvar. |
value | The buffer data for the primvar. |
meshUtil | An HdMeshUtil instance that knows how to triangulate the input buffer data. |
Definition at line 226 of file meshSamplers.h.
|
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
element | The element index to sample. |
u | The u coordinate to sample. |
v | The v coordinate to sample. |
value | The memory to write the value to (only written on success). |
dataType | The HdTupleType describing element values. |
Implements HdEmbreePrimvarSampler.