Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • int numPts: The number of points in the shading context. All non-uniform values can be assumed to have this length.
  • struct scTraits: This struct contains several informational fields.
    • eyePath: A flag which is set to 1 if the shading context was created in the context of an eye path.
    • lightPath: A flag which is set to 1 if the shading context was created in the context of a bidirectional light path.
    • primaryHit: A flag which is set to 1 if the shading context is directly visible to the camera.
    • missContext: A flag which is set to 1 if the shading context represents a ray miss. A miss context has no geometric information associated with it, cannot provide primvar or parameter evaluation services, and the only available builtin variables will be the ones associated with the incident ray.
    • reyesGrid: A flag which is set to 1 if the shading context is associated with a tessellated micropolygon representation. This is true in certain displacement or cached execution contexts.
    • RixSCShadingMode shadingMode: This enumeration conveys the current mode associated with the current shader execution. Knowledge of the shading mode may allow the shader to minimize certain costs associated with the current execution, i.e. by avoiding certain parameter evaluations when it is known that those parameters do not pertain to the current execution.
    • bxdf, opacity, displacement, subsurface, volume: Pointers to instances of the appropriate shader type. It is rare for a shader to need knowledge of other shader types via these fields. If such knowledge is required, the use of the methods GetBxdf(), GetOpacity(), etc is encouraged instead of directly accessing the scTraits
  • int* integratorCtxIndex: This array contains a mapping from the shading context to arrays in the RixIntegratorContext: a shading point of index i is associated with the corresponding index integratorCtxIndex[i]. For example, the shading point with index i can figure out the camera ray that ultimately gave rise to the shading point by accessing the primaryRays[integratorCtxIndex[i]] field of RixIntegratorContext.
  • int* rayId: This array should usually be ignored by shaders. It is typically used by integrators to track a correspondence between the points in the shading context and any ray specific data structures in the integrator.
  • RtColorRGB *transmission: The transmittance associated with the incident ray. This transmittance will typically be non-zero if the incident ray traveled through participating media. Most shaders other than volume integrators will ignore this field, while integrators will need to inspect this field in order to compute the total transmittance along a path.
  • float *pointWeight: If the shading context was created via an importance sampling method, this is the associated weight of that method. Most shaders other than volume integrators will ignore this field, while integrators may need to multiply the shader contributions by this weight.
  • int *pointSampleCount: Only used by volume integrators to indicate the number of samples taken for multiple scattering. Integrators may need to multiply this value into the total path throughput.
  • RtColorRGB *opacityThroughput: Per-point part of the throughput resulting from opacity continuations along the ray that produced the associated hit.
  • RtColorRGB *opacity: Per-point combined opacity: the product of presence and opacity for the given point.
  • float *opacityStochasticWeight: Per-point probability hit-testing weight. Inverse of the probability of having selected this hit. When dealing with non-fully-opaque surfaces, and when using probabilistic hit-testing, the combined opacity can be interpreted as the probability that we actually hit the surface. When only considering a scalar presence value (i.e. opacity is one, so combined opacity is monochromatic), the probability is usually the inverse of the scalar presence value, and no special weighting needs to be applied to the shading on hits. However, when dealing with arbitrary combined opacity, it is necessary to weight the shading on hit by the product of: opacity (the combined opacity on hit), and opacityStochasticWeight ( the inverse hit-testing probability).
  • RixRNG *m_rngCtx: A per-point array of random number contexts. RixRNG *m_rngCtx: A per-point array of random number contexts. These can be used by shaders to generate stratified random numbers. A NULL value here means the current shading mode does not support random number generation, and shader writers should check for a NULL value before relying on these contexts.

...

The first variant of GetPrimVar() can be used to efficiently query the existence, type, and array length of a primvar. The other variants return a pointer to const storage containing the value of the primvar in the var output parameter, if the primvar exists. If the primvar cannot be found, storage will still be allocated and will be filled with the value of the input fill parameter. The optional radius output parameter if supplied will point at storage containing the approximate isotropic filter radius associated with the primvar. This value is computed by the renderer from the ray differentials and can be used to perform any necessary shader antialiasing.

There are also variants of GetPrimVar() which return the partial derivatives of the primvar measured with respect to the builtin variables u and v. These methods may be used in certain conditions that are otherwise hard to filter correctly.

...

by the renderer from the ray differentials and can be used to perform any necessary shader antialiasing.

There are also variants of GetPrimVar() which return the partial derivatives of the primvar measured with respect to the builtin variables u and v. These methods may be used in certain conditions that are otherwise hard to filter correctly.

For normal shading contexts, SetPrimVar() is a no-op. Shaders that wish to change the values of primitive variables will need to create a mutable shading context.

Note

Primitive variables of type RtFloat3 and RtMatrix4x4 are automatically transformed and returned in current space, which is generally considered the optimal space for the renderer to perform operations. Plugin authors should make no assumptions about what current space actually maps to, and should transform such primvars from current to another space if required using the transformation routines.


Anchor
evalparam
evalparam
Parameter Evaluation

...

As long as the RixIntegrator used supports the appropriate ray property query, plugin authors may want to query ray properties such as the ray depth or eye throughput, in order to allow for artistic control or optimization. For instance, as an optimization a RixBxdf may want to skip the evaluation of a particularly expensive lobe, if the current ray depth of the hit point is beyond some arbitrary threshold. This service is provided by the GetProperty() routine on the RixShadingContext. Callers of this routine are responsible for allocating and deallocating the result memory.  The integrator is responsible for filling in the result. Below is a code snippet demonstrating how to use this feature.

Code Block
languagecpp
// Query ray depths for each point in the shading context

...


int

...

 nPts = shadingCtx->numPts;

...


int* rayDepths =

...

 new

...

 int

...

 [nPts];

...


if

...

 (vCtx->GetProperty(k_RayDepth, rayDepths))

...


{
    // Do something expensive for small ray depths, or something cheaper for large

...

 ray depths  
}
delete[] rayDepths;


For documentation on the available ray properties, please consult the integrator ray property query documentationquery documentation.