Shaders and Trace Functions

Trace functions are functions provided by mental ray that allow a shader to cast a ray into the scene, most of them using standard ray tracing. Not all types of tracing functions can be used in all types of shaders. Conversely, many trace functions cause shaders to be called. This section lists these interdependencies.

The following table shows which shaders are called from which trace functions. ◊ means no, ♦ means yes. Displacement, contour, and photon shaders are never called by any of the functions, and may not call any of them.

function calls shader lens mtl env light shad vol
mi_trace_eye
mi_trace_reflection
mi_trace_refraction
mi_trace_transparent
mi_trace_environment
mi_trace_light
mi_sample_light
mi_trace_shadow
mi_trace_shadow_seg

Environment rays do not have entries in this tree. The data in the tree is used for acceleration and can be overridden if a shader wants to cast rays not normally allowed, by setting the state variable state→cache to zero. This should only be done when necessary because it reduces efficiency. The following table shows which trace functions may be called from which shaders:

shader calls function lens mtl env light shad ray
vol
light
vol
mi_trace_eye
mi_trace_reflection ** * ** ** **
mi_trace_refraction ** * ** ** **
mi_trace_transparent ** * ** ** **
mi_trace_environment * *
mi_trace_light * * ** ** **
mi_sample_light * * ** ** **
mi_trace_shadow
mi_trace_shadow_seg

no
yes
*
yes, if the shader generates an artificial intersection point by setting point, normal, and normal_geom in the state.
**
yes, if the shader removes RC's internal ray tree data by setting cache in the state to NULL and generates an artificial intersection point if none is present.

Copyright © 1986-2008 by mental images GmbH