Introduction

RixShadingContext encapsulates a shading context - a description of the environment in which shading is to be performed. It is the primary domain of operation for the shader classes  RixBxdf RixDisplacement RixLight RixPattern , and  RixVolume , and is also of high importance to RixIntegrator . Implementors of these classes and their associated plugins will thus need to be intimately familiar with the RixShadingContext class.

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.

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 geometric properties: 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.





Primitive Variables

Primitive variables (often referred to as primvars) represent values which are optionally present on the geometry. They may be supplied with the geometry definition.

Associated with each primvar is a varying filter size that is computed as a function of rendering conditions such as shading rate and ray differentials. The incoming positions are not guaranteed to be neighbors and so do not support requirements for computing first-differences. Rather, differential information is embodied through filter radii and these are only computable for known builtin and primitive variables.

Traits

shadingCtxTraits conveys a variety of (uniform) ShadingContext traits to shader and integrator.

Memory Management

Allocate is fast memory allocation support from a memory pool tailored to Pattern and Bxdf plugins. Memory allocated via this interface is managed (freed) by RixShadingContext according to the lifetime requirements of the associated MemCategory. As with many custom memory allocation schemes, clients should use "placement new" and not rely on invocation of a destructor. RixAlloca can be used for intra-procedure dynamic memory allocation.

Document New, Allocator etc


 Parameter Evaluation

; any such parameters that are connections may trigger the evaluation of upstream nodes.