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:
  • RtColorRGB *opacity:
  • float *opacityStochasticWeight:
  • 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.

Anchor
getbuiltinvar
getbuiltinvar
Builtin Variables

Builtin variables represent values which are usually always present for all geometry types, and are often used in fundamental shader calculations. Some variables like P, the shading position, and Nn, the normalized shading normal, are derived from the geometry definition. Others like incidentRaySpread and VLen are derived from the incoming rays or from a combination of the geometry definition and the incoming rays.

...

The following diagram illustrates several fundamental builtin variables: the surface position P, the normalized shading normal Nn, and the parametric derivatives dPdu and dPdv, as well as Vlen and Vn which provide information about the incoming ray.


...




Anchor
getprimvar
getprimvar
Primitive Variables

Primitive variables (often referred to as primvars) represent values which may be optionally present on the geometry. These primvars are uniquely named and may be supplied with the geometry definition. Shaders are usually written knowing the name and data type of certain primvars in advance, such as texture coordinates. However, since the primvars are optional, shaders are expected to fail gracefully if the primvars are missing.

...

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.

...

Anchor
evalparam
evalparam
Parameter Evaluation

Evaluation of the input parameters to the shader is provided via the EvalParam() methods. Input parameters may be constant (the direct parameters to the shader invocation), or may be connected to an upstream node and trigger an upstream of that node (and in turn, any of its dependencies). All such upstream computation will be automatically cached by the renderer for the duration of the RixShadingContext.

...