RenderManAPI  24.0
RixShadingContext Class Referenceabstract

RixShadingContext is analogous to a RenderMan grid - it is a group of 1 or more points that may be shaded. More...

#include <RixShading.h>

Inherits RixContext.

Classes

class  Allocator
 Allocator is a utility (fully inlined) class to assist with tedious memory pool allocations. More...
 
struct  Id
 shadingCtxId is a unique identifier for this shading context. More...
 

Public Types

enum  BuiltinVolume { k_SSDiffusion, k_SSPathTraced }
 BuiltinVolumes are "preloaded" and initialized by the renderer. More...
 
enum  BuiltinBxdf { k_NullBxdf }
 BuiltinBxdfs can be constructed cheaply and offer a basic set of capabilities. More...
 
enum  BuiltinVar {
  k_P = 0, k_PRadius, k_Po, k_Nn,
  k_Ngn, k_Non, k_Tn, k_Vn,
  k_VLen, k_curvature, k_incidentRaySpread, k_incidentRayRadius,
  k_incidentLobeSampled, k_mpSize, k_biasR, k_biasT,
  k_geomShadowTermBias, k_u, k_v, k_w,
  k_du, k_dufp = k_du, k_dv, k_dvfp = k_dv,
  k_dw, k_dwfp = k_dw, k_dPdu, k_dPdv,
  k_dPdw, k_dPdtime, k_time, k_Id,
  k_Id2, k_outsideIOR, k_Oi, k_lpeState,
  k_launchShadingCtxId, k_motionFore, k_motionBack, k_curvatureU,
  k_curvatureV, k_dPcameradtime, k_wavelength, k_Naon,
  k_numBuiltinVars
}
 
enum  TransformInterpretation { k_AsPoints, k_AsVectors, k_AsNormals }
 
enum  MemCategory { k_BxdfMem, k_PatternMem }
 

Public Member Functions

bool HasHits () const
 
bool HasMisses () const
 
RixBxdfGetBxdf () const
 
RixOpacityGetOpacity () const
 
RixDisplacementGetDisplacement () const
 
RixVolumeIntegratorGetSubsurface () const
 
RixVolumeIntegratorGetVolume () const
 
RixPostLightingGetPostLighting () const
 
virtual bool HasSubsurface () const =0
 
virtual RixVolumeIntegratorBeginSubsurface (int numRays, RtRayGeometry *rays) const =0
 
virtual void EndSubsurface (RixVolumeIntegrator *) const =0
 
virtual bool HasVolume (RixSCVolumeSelector) const =0
 Support for volume integration: More...
 
virtual RixVolumeIntegratorBeginVolume (RixSCVolumeSelector, int numRays, RtRayGeometry *rays) const =0
 
virtual void EndVolume (RixVolumeIntegrator *) const =0
 
RixVolumeIntegratorBeginIncidentVol (int numRays, RtRayGeometry *rays) const
 two convenience methods More...
 
RixVolumeIntegratorBeginOppositeVol (int numRays, RtRayGeometry *rays) const
 
virtual std::vector< const RixShadingContext * > const * GetOverlappingVolumes () const =0
 Returns a list of shading contexts associated with any overlapping volumes. More...
 
virtual RixVolumeIntegratorGetBuiltinVolume (BuiltinVolume builtin, RixBxdfFactory *factory, void *instanceData) const =0
 
virtual void SetupRngCtxForPattern () const =0
 
virtual RixBxdfGetBuiltinBxdf (BuiltinBxdf, RixBxdfFactory *) const =0
 
virtual RixDisplayServicesGetDisplayServices (int version=1) const =0
 Get access to the display services. More...
 
virtual void GetBuiltinVar (BuiltinVar, int const **var) const =0
 
virtual void GetBuiltinVar (BuiltinVar, float const **var) const =0
 
virtual void GetBuiltinVar (BuiltinVar, RtFloat3 const **var) const =0
 
virtual void GetBuiltinVar (BuiltinVar, RixLPEState *const **var) const =0
 
virtual void SetBuiltinVar (BuiltinVar, float *var)=0
 SetBuiltinVar() allows the values of any builtin variable to be overridden. More...
 
virtual void SetBuiltinVar (BuiltinVar, RtFloat3 *var)=0
 
virtual RixSCDetail GetPrimVar (const RtUString name, RixSCType *type, int *arraylen) const =0
 GetPrimVar: lazily evaluates the named primitive variable. More...
 
virtual RixSCDetail GetPrimVar (const RtUString name, float fill, float const **var, float const **radius=NULL) const =0
 
virtual RixSCDetail GetPrimVar (const RtUString name, RtFloat2 fill, RtFloat2 const **var, float const **radius=NULL) const =0
 
virtual RixSCDetail GetPrimVar (const RtUString name, RtFloat3 fill, RtFloat3 const **var, float const **radius=NULL) const =0
 
virtual RixSCDetail GetPrimVar (const RtUString name, RtUString const **var) const =0
 
virtual RixSCDetail GetPrimVar (const RtUString name, RtMatrix4x4 const &fill, RtMatrix4x4 const **var) const =0
 
virtual RixSCDetail GetPrimVar (const RtUString name, float const **var, float const **dXdu, float const **dXdv) const =0
 This variant of GetPrimVar produces uni/bi/trivariate derivatives of an arbitrary primvar across the surface measured with respect to u and v. More...
 
virtual RixSCDetail GetPrimVar (const RtUString name, RtFloat2 const **var, float const **dXdu, float const **dYdu, float const **dXdv, float const **dYdv) const =0
 
virtual RixSCDetail GetPrimVar (const RtUString name, RtFloat3 const **var, float const **dXdu, float const **dYdu, float const **dZdu, float const **dXdv, float const **dYdv, float const **dZdv) const =0
 
virtual void SetPrimVar (const RtUString name, RixSCDetail d, float *var, float *radius)=0
 SetPrimVar: useful for changing state on mutable shading contexts for consumption by upstream pattern-graph nodes. More...
 
virtual void SetPrimVar (const RtUString name, RixSCDetail d, RtFloat2 *var, float *radius)=0
 
virtual void SetPrimVar (const RtUString name, RixSCDetail d, RtFloat3 *var, float *radius)=0
 
virtual void SetPrimVar (const RtUString name, RixSCDetail d, RtUString *var)=0
 
virtual void SetPrimVar (const RtUString name, RixSCDetail d, RtMatrix4x4 *var)=0
 
virtual bool GetProperty (RayProperty, void const *) const
 As long as the RixIntegrator used supports the appropriate ray property query, shading 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. More...
 
virtual bool SetProperty (RayProperty, void const *) const
 
virtual int Transform (TransformInterpretation interp, const RtUString fromSpace, const RtUString toSpace, RtFloat3 *var, float *radius=NULL) const =0
 Transform an array of RtFloat3 (and optional radius) the same size as the numPts in the RixShadingContext. More...
 
virtual int GetTransform (const RtUString fromSpace, const RtUString toSpace, RtMatrix4x4 const **matrix, int *numMatrices) const =0
 Return an array of matrices numPts in size that represents the transformation from "fromSpace" to "toSpace". More...
 
virtual RixShadingContextCreateMutableContext () const =0
 Create a context that can be mutated (implements SetBuiltinVar) for the purposes of super sampling a pattern network. More...
 
virtual RixShadingContext const * GetPrimaryContext () const =0
 GetPrimaryContext returns a reference to the (immutable) primary shading context. More...
 
virtual RixIntegratorContextGetIntegratorContext () const =0
 Returns a reference to the RixIntegratorContext which created this shading context. More...
 
virtual RixShadingContext const * GetContextById (RixShadingContext::Id sCtxId) const =0
 GetShadingContextById, given a RixShadingContext::Id, returns a reference to the shading context which has a matching Id, or NULL if no such context can be found. More...
 
virtual RixSCDetail EvalParam (int paramId, int arrayIndex, int const **result, int const *dflt=NULL, bool promoteToVarying=false) const =0
 EvalParam. More...
 
virtual RixSCDetail EvalParam (int paramId, int arrayIndex, float const **result, float const *dflt=NULL, bool promoteToVarying=false) const =0
 
virtual RixSCDetail EvalParam (int paramId, int arrayIndex, RtColorRGB const **result, RtColorRGB const *dflt=NULL, bool promoteToVarying=false) const =0
 
virtual RixSCDetail EvalParam (int paramId, int arrayIndex, RtFloat3 const **result, RtFloat3 const *dflt=NULL, bool promoteToVarying=false) const =0
 
virtual RixSCDetail EvalParam (int paramId, int arrayIndex, RtMatrix4x4 const **result, RtMatrix4x4 const *dflt=NULL, bool promoteToVarying=false) const =0
 
virtual RixSCDetail EvalParam (int paramId, int arrayIndex, RtUString const **result, RtUString const *dflt=NULL, bool promoteToVarying=false) const =0
 
virtual RixSCDetail EvalParam (int paramId, int arrayIndex, RixBxdfFactory **result, RixBxdfFactory *dflt=NULL, bool promoteToVarying=false) const =0
 
template<class T >
RixSCDetail EvalAndCopyParam (int paramId, int arrayIndex, T **result, T const *dflt=NULL, bool promoteToVarying=false, MemCategory mcat=k_BxdfMem) const
 EvalAndCopyParam: Templated convenience routine for callers who need to modify input parameters. More...
 
virtual int GetParamId (const RtUString name, int *paramId) const =0
 GetParamId maps a string name to a more efficient integer reference. More...
 
virtual int GetParamInfo (int paramId, RixSCType *type, RixSCConnectionInfo *cInfo, int *arrayLength=NULL) const =0
 GetParamInfo returns additional detail about the parameter such as its connection status, type, and array length. More...
 
int GetParamInfo (int paramId, RixSCType *type, bool *isConnected, int *arrayLength=NULL) const
 This version of GetParamInfo is a convenience for use-cases where a bool notion of connection is sufficient. More...
 
virtual void GetNearestHits (int numRays, RtRayGeometry const *rays, RtHitPoint *hits, const RtUString subset=US_NULL, const RtUString excludeSubset=US_NULL, RtHitSides hitSides=k_SidesBoth) const =0
 GetNearestHits: traces rays to determine the nearest hit in the given direction. More...
 
virtual bool GetLightEmission (RtColorRGB *emission, int *lightGroupIds=NULL) const =0
 GetLightEmission: returns the sampled emission associated with the shading points. More...
 
virtual void * Allocate (size_t n, size_t size, MemCategory m) const =0
 Allocate: fast memory allocation support from a memory pool tailored to Pattern and Bxdf plugins. More...
 
template<class T >
T * New (size_t nObjs, MemCategory cat=k_BxdfMem) const
 New is a utility (fully inlined) non-virtual method to assist with tedious memory allocation tasks. More...
 
virtual RixInterfaceGetRixInterface (RixInterfaceId id) const =0
 Get the specified interface from this context. More...
 

Public Attributes

struct RixShadingContext::Id shadingCtxId
 
int numPts
 numPts is the number of shading points. More...
 
struct {
   unsigned   eyePath: 1
 
   unsigned   lightPath: 1
 true if shading for an eye path More...
 
   unsigned   primaryHit: 1
 true if shading for a light path More...
 
   unsigned   missContext: 1
 true if shading for a first hit More...
 
   unsigned   reyesGrid: 1
 true if this context represents misses More...
 
   RixSCShadingMode   shadingMode
 true if we're operating on a reyes grid this may occur in a variety of caching conditions More...
 
   RixBxdf *   bxdf
 The bxdf shader is non-NULL for radiance queries and is responsible for computing light scattering. More...
 
   RixOpacity *   opacity
 
   RixDisplacement *   displacement
 
   RixVolumeIntegrator *   subsurface
 
   RixVolumeIntegrator *   volume
 
   RixPostLighting *   postlighting
 
scTraits
 shadingCtxTraits conveys a variety of (uniform) ShadingContex traits to shader and integrator. More...
 
int * integratorCtxIndex
 integratorCtxIndex maps indices to varying ShadingContext entries to the index associated with IntegratorContext. More...
 
int * rayId
 rayId is similar to integratorCtxIndex. More...
 
RtColorRGBtransmission
 transmission is a per-point transmission that is associated with the ray that produced the associated hit. More...
 
RtColorRGBmatteTransmission
 Similar to transmission but restricted to the transmittance computed solely from matte or holdout volumes. More...
 
RtColorRGBpointWeight
 If the shading context was created via an importance sampling method, this is the associated weight the integrator needs to multiply in. More...
 
int * pointSampleCount
 If multiple volume samples are taken for multi scattering, the integrator needs to multiply this value in for thruput. More...
 
RtColorRGBopacityThroughput
 
RtColorRGBopacity
 
float * opacityStochasticWeight
 
void * lightingServicesData
 lightingServicesData is a blind pointer private RixLightingServices data More...
 
RixLight const * light
 
RixRNGm_rngCtx
 

Protected Member Functions

 ~RixShadingContext () override
 
virtual RixShadingContextBeginVolumeSampling () const =0
 
virtual RixShadingContext const * EndVolumeSampling (const RixShadingContext *, RixBXLobeTraits const *exposeVol=NULL, int const *membership=NULL) const =0
 

Protected Attributes

RixRNG::SampleCtxm_rngSampleCtx
 

Friends

class RixVolumeIntegrator
 
class LightVertexCache
 

Detailed Description

RixShadingContext is analogous to a RenderMan grid - it is a group of 1 or more points that may be shaded.

The group of points usually arrive through ray traced "hits". In this case, the shading context provides geometric details through its GetPrimVar and GetBuiltinVar methods. 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.

ShadingContexts can also be produced by ray traced "misses". Now only the ray origination information is available and the class of shading activities is limited to cases where no bxdf, builtin and primitive variables are required. RixShadingContexts are comprised exclusively of hits or misses and optionally delivered across the RixIntegratorContext's GetNearestHits method.

ShadingContexts operate in a small number of modes according to the integration requirements.

Member Enumeration Documentation

◆ BuiltinBxdf

BuiltinBxdfs can be constructed cheaply and offer a basic set of capabilities.

They differ from Bxdf plugins in that they expose no parameters and thus no BxdfFactories are required.

Enumerator
k_NullBxdf 

◆ BuiltinVar

Enumerator
k_P 

Shading position (type RtFloat3)

k_PRadius 

When raytracing, the ray footprint radius at P, otherwise the micropolygon radius (ie half mpSize) at P (type float)

k_Po 

Undisplaced P (type RtFloat3)

k_Nn 

Normalized shading normal (type RtFloat3)

k_Ngn 

Normalized geometric normal (type RtFloat3)

k_Non 

Normalized undisplaced N (type RtFloat3)

k_Tn 

Normalized shading tangent (type RtFloat3)

k_Vn 

Normalized view vector, points away from shading points (type RtFloat3)

k_VLen 

Length of view vector (type float)

k_curvature 

Local mean surface curvature (type float)

k_incidentRaySpread 

Spread of incident ray (type float): how much the ray radius increased for each unit distance the ray travelled.

k_incidentRayRadius 

Radius of incident ray at P (type float)

k_incidentLobeSampled 

RixBXLobeSampled id of incident rays (type int)

k_mpSize 

Micropolygon size; 0 for non-tessellated surfaces (type float)

k_biasR 

Bias to apply for reflected rays (type float)

k_biasT 

Bias to apply for transmitted rays (type float)

k_geomShadowTermBias 

Bias to apply for shadow rays (Direct Light) to avoid the geometric shadow terminator.

k_u 

Surface U parameterization (type float)

k_v 

Surface V parameterization (type float)

k_w 

Surface W parameterization (type float)

k_du 

Ray footprint (radius) in U (type float)

k_dufp 
k_dv 

Ray footprint (radius) in V (type float)

k_dvfp 
k_dw 

Ray footprint (radius) in W (type float)

k_dwfp 
k_dPdu 

Surface derivative in U (type RtFloat3)

k_dPdv 

Surface derivative in V (type RtFloat3)

k_dPdw 

Surface derivative in W (type RtFloat3)

k_dPdtime 

Instantaneous P velocity relative to the world (type RtFloat3)

k_time 

Shading time, normalized between shutter open and close (type float)

k_Id 

Attribute "identifier" "id" (type int)

k_Id2 

Attribute "identifier" "id2" (type int)

k_outsideIOR 

Incident index of refraction (type float)

k_Oi 

Opacity (type RtFloat3)

k_lpeState 

Current LPE State (type RixLPEState)

k_launchShadingCtxId 

Parent ray shading context serialization (type int)

k_motionFore 

Forward 2D raster-space motion vector (type RtFloat3)

k_motionBack 

Backward 2D raster-space motion vector (type RtFloat3)

k_curvatureU 

Local principal surface curvature in u dir (type float)

k_curvatureV 

Local principal surface curvature in v dir (type float)

k_dPcameradtime 

Instantaneous P velocity relative to the camera (type RtFloat3)

k_wavelength 

Wavelength of incident ray (type float): 380-780nm visible spectrum.

k_Naon 

Normalized analytical undisplaced N (type RtFloat3)

k_numBuiltinVars 

◆ BuiltinVolume

BuiltinVolumes are "preloaded" and initialized by the renderer.

Plugin volumes are usually "compiled-in" to the associated Bxdf. In both cases, the Bxdf's BeginInterior method is invoked to instantiate a VolumeIntegrator object.

Enumerator
k_SSDiffusion 
k_SSPathTraced 

◆ MemCategory

Enumerator
k_BxdfMem 
k_PatternMem 

◆ TransformInterpretation

Enumerator
k_AsPoints 
k_AsVectors 
k_AsNormals 

Constructor & Destructor Documentation

◆ ~RixShadingContext()

RixShadingContext::~RixShadingContext ( )
inlineoverrideprotected

Member Function Documentation

◆ Allocate()

virtual void* RixShadingContext::Allocate ( size_t  n,
size_t  size,
MemCategory  m 
) const
pure virtual

Allocate: 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.

Referenced by RixShadingContext::Allocator::Allocate(), RixShadingContext::Allocator::AllocFor(), RixShadingContext::Allocator::AllocForBxdf(), RixShadingContext::Allocator::AllocForPattern(), RixShadingContext::Allocator::AllocForVolume(), EvalAndCopyParam(), and New().

◆ BeginIncidentVol()

RixVolumeIntegrator* RixShadingContext::BeginIncidentVol ( int  numRays,
RtRayGeometry rays 
) const
inline

two convenience methods

References BeginVolume(), and k_RixSCIncidentVolume.

◆ BeginOppositeVol()

RixVolumeIntegrator* RixShadingContext::BeginOppositeVol ( int  numRays,
RtRayGeometry rays 
) const
inline

◆ BeginSubsurface()

virtual RixVolumeIntegrator* RixShadingContext::BeginSubsurface ( int  numRays,
RtRayGeometry rays 
) const
pure virtual

◆ BeginVolume()

virtual RixVolumeIntegrator* RixShadingContext::BeginVolume ( RixSCVolumeSelector  ,
int  numRays,
RtRayGeometry rays 
) const
pure virtual

◆ BeginVolumeSampling()

virtual RixShadingContext* RixShadingContext::BeginVolumeSampling ( ) const
protectedpure virtual

◆ CreateMutableContext()

virtual RixShadingContext* RixShadingContext::CreateMutableContext ( ) const
pure virtual

Create a context that can be mutated (implements SetBuiltinVar) for the purposes of super sampling a pattern network.

The mutable context is created in the Bxdf memory of its parent context and does not need to be released. It will be automatically reclaimed when its parent context is released.

◆ EndSubsurface()

virtual void RixShadingContext::EndSubsurface ( RixVolumeIntegrator ) const
pure virtual

◆ EndVolume()

virtual void RixShadingContext::EndVolume ( RixVolumeIntegrator ) const
pure virtual

◆ EndVolumeSampling()

virtual RixShadingContext const* RixShadingContext::EndVolumeSampling ( const RixShadingContext ,
RixBXLobeTraits const *  exposeVol = NULL,
int const *  membership = NULL 
) const
protectedpure virtual

◆ EvalAndCopyParam()

template<class T >
RixSCDetail RixShadingContext::EvalAndCopyParam ( int  paramId,
int  arrayIndex,
T **  result,
T const *  dflt = NULL,
bool  promoteToVarying = false,
MemCategory  mcat = k_BxdfMem 
) const
inline

EvalAndCopyParam: Templated convenience routine for callers who need to modify input parameters.

Use with care as it incurs an additional memory allocation and memcpy. NB: only a subset of types produce meaningfully writable results. RtUStrings, RixBxdfFactory are not among them.

References Allocate(), EvalParam(), k_RixSCUniform, and k_RixSCVarying.

◆ EvalParam() [1/7]

virtual RixSCDetail RixShadingContext::EvalParam ( int  paramId,
int  arrayIndex,
int const **  result,
int const *  dflt = NULL,
bool  promoteToVarying = false 
) const
pure virtual

EvalParam.

Id-based parameter evaluation captures the data flow through graph of connected RixPattern and RixBxdf nodes.

A parameter can be constant or computed. Calls to the Eval method of non-constant parameters may trigger function evaluation. Parameter values may be cached by the renderer for the duration of an execution context (see RixBxdf Begin/End).

Calls to EvalParam must fill an entire ShadingContext of values. The exception to this rule is for RixBxdf composition where a RixBxdf may be obtained. In that case, the 'driver' Bxdf is expected to distribute Begin/Eval/Generate/End messages to subservient Bxdf instances.

Parameter evaluation: Bxdfs and Patterns invoke EvalParam to sample their inputs. Since inputs may or may not obtain values from upstream, the detail, obtained via GetParamInfo, can be consulted to hoist expensive computations out of per-point loops. Again, caller is expected to know the type of its parameters. If the optional EvalParam parameter, promoteToVarying is true, then the detail of the result is guaranteed to be k_RixSCVarying but the returned detail will be that associated with the actual connection state. EvalParam works for array elements as well as simple parameters. In the simple-case, set arrayIndex to -1. Result is const and should usually not be overwritten by by caller.. It's common for Bxdf's to wish to conform (clamp) their inputs to reasonable ranges and this can be done only in bxdf nodes and only by const_cast-ing. If a value can't be obtained via the network nor the Ri parameterlist, we fill the result with the default value provided. If the default value isn't provided we return RixSCInvalidDetail.

Referenced by EvalAndCopyParam(), RixShadingParam::InitEvalC(), RixShadingParam::InitEvalF(), RixShadingParam::InitEvalI(), and RixShadingParam::InitEvalV().

◆ EvalParam() [2/7]

virtual RixSCDetail RixShadingContext::EvalParam ( int  paramId,
int  arrayIndex,
float const **  result,
float const *  dflt = NULL,
bool  promoteToVarying = false 
) const
pure virtual

◆ EvalParam() [3/7]

virtual RixSCDetail RixShadingContext::EvalParam ( int  paramId,
int  arrayIndex,
RtColorRGB const **  result,
RtColorRGB const *  dflt = NULL,
bool  promoteToVarying = false 
) const
pure virtual

◆ EvalParam() [4/7]

virtual RixSCDetail RixShadingContext::EvalParam ( int  paramId,
int  arrayIndex,
RtFloat3 const **  result,
RtFloat3 const *  dflt = NULL,
bool  promoteToVarying = false 
) const
pure virtual

◆ EvalParam() [5/7]

virtual RixSCDetail RixShadingContext::EvalParam ( int  paramId,
int  arrayIndex,
RtMatrix4x4 const **  result,
RtMatrix4x4 const *  dflt = NULL,
bool  promoteToVarying = false 
) const
pure virtual

◆ EvalParam() [6/7]

virtual RixSCDetail RixShadingContext::EvalParam ( int  paramId,
int  arrayIndex,
RtUString const **  result,
RtUString const *  dflt = NULL,
bool  promoteToVarying = false 
) const
pure virtual

◆ EvalParam() [7/7]

virtual RixSCDetail RixShadingContext::EvalParam ( int  paramId,
int  arrayIndex,
RixBxdfFactory **  result,
RixBxdfFactory dflt = NULL,
bool  promoteToVarying = false 
) const
pure virtual

◆ GetBuiltinBxdf()

virtual RixBxdf* RixShadingContext::GetBuiltinBxdf ( BuiltinBxdf  ,
RixBxdfFactory  
) const
pure virtual

◆ GetBuiltinVar() [1/4]

virtual void RixShadingContext::GetBuiltinVar ( BuiltinVar  ,
int const **  var 
) const
pure virtual

◆ GetBuiltinVar() [2/4]

virtual void RixShadingContext::GetBuiltinVar ( BuiltinVar  ,
float const **  var 
) const
pure virtual

◆ GetBuiltinVar() [3/4]

virtual void RixShadingContext::GetBuiltinVar ( BuiltinVar  ,
RtFloat3 const **  var 
) const
pure virtual

◆ GetBuiltinVar() [4/4]

virtual void RixShadingContext::GetBuiltinVar ( BuiltinVar  ,
RixLPEState *const **  var 
) const
pure virtual

◆ GetBuiltinVolume()

virtual RixVolumeIntegrator* RixShadingContext::GetBuiltinVolume ( BuiltinVolume  builtin,
RixBxdfFactory factory,
void *  instanceData 
) const
pure virtual

◆ GetBxdf()

◆ GetContextById()

virtual RixShadingContext const* RixShadingContext::GetContextById ( RixShadingContext::Id  sCtxId) const
pure virtual

GetShadingContextById, given a RixShadingContext::Id, returns a reference to the shading context which has a matching Id, or NULL if no such context can be found.

It is the responsibility of the integrator and the caller to ensure that the shading context has not been returned to the system via RixIntegratorContext::ReleaseShadingContexts.

◆ GetDisplacement()

RixDisplacement* RixShadingContext::GetDisplacement ( ) const
inline

◆ GetDisplayServices()

virtual RixDisplayServices* RixShadingContext::GetDisplayServices ( int  version = 1) const
pure virtual

Get access to the display services.

This is the same display service normally offered by the integrator context but is provided here to allow RixPatterns and RixBXDFs to bypass the integrator and write directly into AOV channels for special effects.

◆ GetIntegratorContext()

virtual RixIntegratorContext* RixShadingContext::GetIntegratorContext ( ) const
pure virtual

Returns a reference to the RixIntegratorContext which created this shading context.

◆ GetLightEmission()

virtual bool RixShadingContext::GetLightEmission ( RtColorRGB emission,
int *  lightGroupIds = NULL 
) const
pure virtual

GetLightEmission: returns the sampled emission associated with the shading points.

Nonzero return values are only expected if the shading context is asssociated with a direct light source. This should not be confused with the results of the LocalEmission of a Bxdf, but might overlap as with PxrLightEmission.

◆ GetNearestHits()

virtual void RixShadingContext::GetNearestHits ( int  numRays,
RtRayGeometry const *  rays,
RtHitPoint hits,
const RtUString  subset = US_NULL,
const RtUString  excludeSubset = US_NULL,
RtHitSides  hitSides = k_SidesBoth 
) const
pure virtual

GetNearestHits: traces rays to determine the nearest hit in the given direction.

Both arrays must be at least numRays long. Misses are indicated in the RtHitPoint via hits[i].dist == 0. An optional trace subset can be provided to further constrain objects considered. Clients should include RixIntegrator.h for the definition of RtRayGeometry and RtHitPoint structs.

Parameters
[in]numRaysNumber of rays to trace. Cannot be larger than RixIntegratorContext::k_MaxRaysPerBatch.
[in]raysThe rays to trace. Array of size numRays.
[out]hitsResulting ray hits from tracing rays.
[in]subsetThe method will only yield hits on objects whose group membership matches subset.
[in]excludeSubsetThe method will ignore hits on objects whose group membership matches excludeSubset.
[in]hitSidesThe method will only yields hits on the indicated side of objects.

◆ GetOpacity()

RixOpacity* RixShadingContext::GetOpacity ( ) const
inline

◆ GetOverlappingVolumes()

virtual std::vector<const RixShadingContext*> const* RixShadingContext::GetOverlappingVolumes ( ) const
pure virtual

Returns a list of shading contexts associated with any overlapping volumes.

◆ GetParamId()

virtual int RixShadingContext::GetParamId ( const RtUString  name,
int *  paramId 
) const
pure virtual

GetParamId maps a string name to a more efficient integer reference.

The paramId may be negative to support dynamic inputs. Non-negative values are indices into the parameter table, while negative values are interpretted as indices into the parameterlist of a RIB instance. Returns 0 on success, returns nonzero if named parameter is not found.

◆ GetParamInfo() [1/2]

virtual int RixShadingContext::GetParamInfo ( int  paramId,
RixSCType type,
RixSCConnectionInfo cInfo,
int *  arrayLength = NULL 
) const
pure virtual

GetParamInfo returns additional detail about the parameter such as its connection status, type, and array length.

Its primary use is during pattern-graph execution to determine connectivity or dynamic array sizes. Returns 0 on success, nonzero on failure.

Referenced by GetParamInfo().

◆ GetParamInfo() [2/2]

int RixShadingContext::GetParamInfo ( int  paramId,
RixSCType type,
bool *  isConnected,
int *  arrayLength = NULL 
) const
inline

This version of GetParamInfo is a convenience for use-cases where a bool notion of connection is sufficient.

References GetParamInfo(), and k_RixSCNetworkValue.

◆ GetPostLighting()

RixPostLighting* RixShadingContext::GetPostLighting ( ) const
inline

◆ GetPrimaryContext()

virtual RixShadingContext const* RixShadingContext::GetPrimaryContext ( ) const
pure virtual

GetPrimaryContext returns a reference to the (immutable) primary shading context.

Only in a case where the caller is operating on a mutable context created by a downstream node should the returned value differ from the invoking ShadingContext.

◆ GetPrimVar() [1/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
RixSCType type,
int *  arraylen 
) const
pure virtual

GetPrimVar: lazily evaluates the named primitive variable.

Caller is expected to know the datatype in advance and invoke the correct variant. The first variant can be used to efficiently query the existence, type and arrayLength of an primvar. The optional radius parameter is filled with an approximate isotropic filter radius associated with the projected ray differentials of each shading point. If the primvar cannot be found, the return value is initialized with the fill value and the return value is k_RixSCInvalidDetail.

Referenced by RixBump().

◆ GetPrimVar() [2/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
float  fill,
float const **  var,
float const **  radius = NULL 
) const
pure virtual

◆ GetPrimVar() [3/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
RtFloat2  fill,
RtFloat2 const **  var,
float const **  radius = NULL 
) const
pure virtual

◆ GetPrimVar() [4/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
RtFloat3  fill,
RtFloat3 const **  var,
float const **  radius = NULL 
) const
pure virtual

◆ GetPrimVar() [5/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
RtUString const **  var 
) const
pure virtual

◆ GetPrimVar() [6/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
RtMatrix4x4 const &  fill,
RtMatrix4x4 const **  var 
) const
pure virtual

◆ GetPrimVar() [7/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
float const **  var,
float const **  dXdu,
float const **  dXdv 
) const
pure virtual

This variant of GetPrimVar produces uni/bi/trivariate derivatives of an arbitrary primvar across the surface measured with respect to u and v.

This function is useful in unusual geometric supersampling conditions and for bump mapping. The simpler variant is preferred over this method unless the special features are required.

◆ GetPrimVar() [8/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
RtFloat2 const **  var,
float const **  dXdu,
float const **  dYdu,
float const **  dXdv,
float const **  dYdv 
) const
pure virtual

◆ GetPrimVar() [9/9]

virtual RixSCDetail RixShadingContext::GetPrimVar ( const RtUString  name,
RtFloat3 const **  var,
float const **  dXdu,
float const **  dYdu,
float const **  dZdu,
float const **  dXdv,
float const **  dYdv,
float const **  dZdv 
) const
pure virtual

◆ GetProperty()

virtual bool RixShadingContext::GetProperty ( RayProperty  ,
void const *   
) const
inlinevirtual

As long as the RixIntegrator used supports the appropriate ray property query, shading 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 GetProperty(). Callers of this routine are responsible for allocating and deallocating the result memory. The integrator is responsible for filling in the result.

Referenced by PxrGeoAOV::Splat().

◆ GetRixInterface()

virtual RixInterface* RixContext::GetRixInterface ( RixInterfaceId  id) const
pure virtualinherited

Get the specified interface from this context.

The generic interface that is returned must be cast to the appropriate type before use.

Referenced by PxrGeoAOV::disableIntegratorAOVs(), RixIES::ReadIESProfile(), RixBXLookupLobeByName(), RixDebugBasis(), RixGetSceneColorSpace(), RixIsHoldout(), and RixIsMatte().

◆ GetSubsurface()

RixVolumeIntegrator* RixShadingContext::GetSubsurface ( ) const
inline

◆ GetTransform()

virtual int RixShadingContext::GetTransform ( const RtUString  fromSpace,
const RtUString  toSpace,
RtMatrix4x4 const **  matrix,
int *  numMatrices 
) const
pure virtual

Return an array of matrices numPts in size that represents the transformation from "fromSpace" to "toSpace".

If the transformation is time varying, the numMatrices returned will be the same as numPts in the RixShadingContext. If the transformation is uniform, numMatrices will be set to 1. Zero is returned on success. If fromSpace or toSpace is US_NULL or an empty string, "current" is used instead.

◆ GetVolume()

◆ HasHits()

bool RixShadingContext::HasHits ( ) const
inline

References scTraits.

Referenced by PxrGeoAOV::Splat().

◆ HasMisses()

bool RixShadingContext::HasMisses ( ) const
inline

References scTraits.

◆ HasSubsurface()

virtual bool RixShadingContext::HasSubsurface ( ) const
pure virtual

◆ HasVolume()

virtual bool RixShadingContext::HasVolume ( RixSCVolumeSelector  ) const
pure virtual

Support for volume integration:

Begin/EndVolume: can be called by primary integrators to acquire a volume integrator for the selected volume subset (incident or opposite). Depending on the ray path and the requirements of the volume integrator itself, the resulting volume integrator may be bound to a different shading context that was associated with the originating rays. For this reason the incoming ray geometries must be non-const, their shadingCtxIndex may change.

◆ New()

template<class T >
T* RixShadingContext::New ( size_t  nObjs,
MemCategory  cat = k_BxdfMem 
) const
inline

New is a utility (fully inlined) non-virtual method to assist with tedious memory allocation tasks.

Note that class-constructor methods may be run on array entries. This cost should be carefully considered for high performance requirements.

References Allocate().

◆ SetBuiltinVar() [1/2]

virtual void RixShadingContext::SetBuiltinVar ( BuiltinVar  ,
float *  var 
)
pure virtual

SetBuiltinVar() allows the values of any builtin variable to be overridden.

However, for normal shading contexts, SetBuiltinVar() is a no-op. Shaders that wish to change the values of builtin variables must operate on a mutable shading context.

The caller is responsible for providing a pointer to memory allocated with a full RixShadingContext::numPts worth of allocation. This memory will subsequently be owned by the RixShadingContext, and therefore should be allocated using the RixShadingContext's own memory allocation methods (i.e. Allocate()) using the appropriate hint for Bxdf memory duration.

Normally, a shader that alters any single builtin variable is responsible for ensuring that all other builtin variables are also updated appropriately. As a special exception to this, any alteration of the builtin variables u, v, or w by a surface shader will automatically trigger recomputation of P, dPdu, dPdv, and Nn to reflect the updated values of u, v, w, as well as any other builtins that are derived from those values. All other built-in variables will be flushed from the cache and recomputed as necessary. For volume shading, any alteration of P will automatically trigger recomputation of all built-in variables derived from P.

Referenced by RixShiftCtxInU(), and RixShiftCtxInV().

◆ SetBuiltinVar() [2/2]

virtual void RixShadingContext::SetBuiltinVar ( BuiltinVar  ,
RtFloat3 var 
)
pure virtual

◆ SetPrimVar() [1/5]

virtual void RixShadingContext::SetPrimVar ( const RtUString  name,
RixSCDetail  d,
float *  var,
float *  radius 
)
pure virtual

SetPrimVar: useful for changing state on mutable shading contexts for consumption by upstream pattern-graph nodes.

However, for normal shading contexts, SetPrimVar() is a no-op. Shaders that wish to change the values of builtin variables must operate on a mutable shading context. The caller is responsible for providing a pointer to memory allocated with a full RixShadingContext::numPts worth of allocation. This memory will subsequently be owned by the RixShadingContext, and therefore should be allocated using the RixShadingContext's own memory allocation methods (i.e. Allocate()) using the appropriate hint for Bxdf memory duration.

Unlike GetPrimVar(), SetPrimVar() allows for the creation of primitive variables that are not specified in the original geometry description.

◆ SetPrimVar() [2/5]

virtual void RixShadingContext::SetPrimVar ( const RtUString  name,
RixSCDetail  d,
RtFloat2 var,
float *  radius 
)
pure virtual

◆ SetPrimVar() [3/5]

virtual void RixShadingContext::SetPrimVar ( const RtUString  name,
RixSCDetail  d,
RtFloat3 var,
float *  radius 
)
pure virtual

◆ SetPrimVar() [4/5]

virtual void RixShadingContext::SetPrimVar ( const RtUString  name,
RixSCDetail  d,
RtUString var 
)
pure virtual

◆ SetPrimVar() [5/5]

virtual void RixShadingContext::SetPrimVar ( const RtUString  name,
RixSCDetail  d,
RtMatrix4x4 var 
)
pure virtual

◆ SetProperty()

virtual bool RixShadingContext::SetProperty ( RayProperty  ,
void const *   
) const
inlinevirtual

◆ SetupRngCtxForPattern()

virtual void RixShadingContext::SetupRngCtxForPattern ( ) const
pure virtual

◆ Transform()

virtual int RixShadingContext::Transform ( TransformInterpretation  interp,
const RtUString  fromSpace,
const RtUString  toSpace,
RtFloat3 var,
float *  radius = NULL 
) const
pure virtual

Transform an array of RtFloat3 (and optional radius) the same size as the numPts in the RixShadingContext.

The type of transformation is specified with TransformInterpretation. If fromSpace or toSpace is US_NULL or an empty string, "current" is used instead. If the call is successful it will return 0.

Friends And Related Function Documentation

◆ LightVertexCache

friend class LightVertexCache
friend

◆ RixVolumeIntegrator

friend class RixVolumeIntegrator
friend

Member Data Documentation

◆ bxdf

RixBxdf* RixShadingContext::bxdf

The bxdf shader is non-NULL for radiance queries and is responsible for computing light scattering.

◆ displacement

RixDisplacement* RixShadingContext::displacement

◆ eyePath

unsigned RixShadingContext::eyePath

◆ integratorCtxIndex

int* RixShadingContext::integratorCtxIndex

integratorCtxIndex maps indices to varying ShadingContext entries to the index associated with IntegratorContext.

The ith element of our integratorCtxIndex tells us the index of the associated primaryRay and other subsidiary channels. The integratorCtxIndex is critical for proper integrator functionality and should be considered "opaque" to the Bxdf.

Referenced by RtRayGeometry::InitOrigination(), RtRayGeometry::InitTransmitOrigination(), and RixIntegrator::IntegrateRays().

◆ light

RixLight const* RixShadingContext::light

◆ lightingServicesData

void* RixShadingContext::lightingServicesData
mutable

lightingServicesData is a blind pointer private RixLightingServices data

◆ lightPath

unsigned RixShadingContext::lightPath

true if shading for an eye path

◆ m_rngCtx

RixRNG* RixShadingContext::m_rngCtx
mutable

◆ m_rngSampleCtx

RixRNG::SampleCtx* RixShadingContext::m_rngSampleCtx
mutableprotected

◆ matteTransmission

RtColorRGB* RixShadingContext::matteTransmission

Similar to transmission but restricted to the transmittance computed solely from matte or holdout volumes.

◆ missContext

unsigned RixShadingContext::missContext

true if shading for a first hit

◆ numPts

int RixShadingContext::numPts

numPts is the number of shading points.

All other non-uniform values can be assumed to have this length.

Referenced by RixIntegrator::IntegrateRays(), RixBump(), RixFresnelDielectric(), RixShiftCtxInU(), RixShiftCtxInV(), and PxrGeoAOV::Splat().

◆ opacity [1/2]

RixOpacity* RixShadingContext::opacity

◆ opacity [2/2]

RtColorRGB* RixShadingContext::opacity

◆ opacityStochasticWeight

float* RixShadingContext::opacityStochasticWeight

◆ opacityThroughput

RtColorRGB* RixShadingContext::opacityThroughput

◆ pointSampleCount

int* RixShadingContext::pointSampleCount

If multiple volume samples are taken for multi scattering, the integrator needs to multiply this value in for thruput.

◆ pointWeight

RtColorRGB* RixShadingContext::pointWeight

If the shading context was created via an importance sampling method, this is the associated weight the integrator needs to multiply in.

◆ postlighting

RixPostLighting* RixShadingContext::postlighting

◆ primaryHit

unsigned RixShadingContext::primaryHit

true if shading for a light path

◆ rayId

int* RixShadingContext::rayId

rayId is similar to integratorCtxIndex.

This array can be used by integrators to track a correspondence between the ShadingContext entries and integrator-specific data structures. The rayId may be critical for proper functionality of a given integrator and should be considered "opaque" to the Bxdf.

◆ reyesGrid

unsigned RixShadingContext::reyesGrid

true if this context represents misses

◆ scTraits

struct { ... } RixShadingContext::scTraits

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

Referenced by GetBxdf(), GetDisplacement(), GetOpacity(), GetPostLighting(), GetSubsurface(), GetVolume(), HasHits(), and HasMisses().

◆ shadingCtxId

struct RixShadingContext::Id RixShadingContext::shadingCtxId

◆ shadingMode

RixSCShadingMode RixShadingContext::shadingMode

true if we're operating on a reyes grid this may occur in a variety of caching conditions

shadingMode contains the current mode of operation associated with this shading context.

◆ subsurface

RixVolumeIntegrator* RixShadingContext::subsurface

◆ transmission

RtColorRGB* RixShadingContext::transmission

transmission is a per-point transmission that is associated with the ray that produced the associated hit.

It's used by interiors and volumes to "occlude" the results of the radiance computation of each point.

◆ volume

RixVolumeIntegrator* RixShadingContext::volume

The documentation for this class was generated from the following file: