...
A RixShadingContext
usually represents a collection of one or more geometric points that may be shaded. The group of points may arrive via ray tracing hits on geometry, or may be associated with tessellated micropolygons. In either case, shaders will make use of the shading context primarily in one of two ways: inquiring about geometric information through the GetPrimVar()
and GetBuiltinVar()
methods, and evaluation of the input parameters to the shading function is provided via the EvalParam()
methods.
Generally, a shader should consider its associated shading context to be const
read only. Shaders that need to write to the shading context will need to use a mutable shading context.
Fields
A RixShadingContext
contains several fields that will be filled in by the renderer or integrator and may contain useful information pertinent to shading computations. For all shader types, this information should be considered read-only, which is enforced through the use of a const RixShadingContext
. RixIntegrator
plugins may be required to fill in some of these fields through the course of their operation.
...
BuiltinVar
must be passed a pointer to a pointer of the appropriate type for the variable. The returned pointer points at const storage containing the value of the variable, one value for each point in the RixShadingContext
. This storage is owned by the renderer and is valid for the duration of the shader execution.
For normal shading contexts, SetBuiltinVar()
is a no-op. Shaders that wish to change the values of builtin variables will need to create a mutable shading context.
The following diagram illustrates several fundamental builtin variables: the surface position P
, the normalized shading normal Nn
and the normalized shading tangent Tn
, the geometric normal Ngn
, and the parametric derivatives dPdu
and dPdv.
...
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.
Anchorevalparam evalparam
Parameter Evaluation
evalparam | |
evalparam |
...