Whenever a ray is cast the following state variables are set to describe the ray:

type name content
miState * parent state of parent shader
miState * child state of child shader
miRay_type type type of ray: reflect, light...
miCBoolean scanline from scanline algorithm
void * cache RC intersection cache
miVector org start point of the ray
miVector dir direction of the ray
float time shutter interval time
miTag volume volume shader of primitive
miTag environment environment shader
int reflection_level current reflection ray depth
int refraction_level current refraction ray depth
int face facing flag for sub-rays
Points to the state of the parent ray. In the first lens shader, it is NULL. In subsequent lens shaders, it points to the previous lens shader. In the material shader that is called when the primary ray hits an object, it points to the last lens shader's state, or is NULL if no lens shader has been applied. For material shaders called when a secondary reflection or refraction ray hits an object, it points to the parent material shader that cast the ray. In light shaders and environment shaders, it points to the state of the shader which requested the light or environment lookup. For shadow shaders, it points to the state of the light shader that started the shadow trace. In volume shaders, its value is the same as for a material or light shader of the same ray.
Points to the state of the most recent child ray. After a function that created a separate state returns, this state is still accessible to the caller of the function through this pointer. For example, mi_trace_refraction constructs a state when hitting geometry before calling the material shader attached to that geometry with this state. After it returns, the new state can be accessed by the caller of mi_trace_refraction to access state→user, state→label, and all other local information.
Specifies the reason for this ray. This is an enumerator.
primary rays from the camera.
transparency rays cast by a material shader.
refraction rays cast by a material shader.
reflection rays cast by a material shader.
light rays cast from a light source.
rays cast by a material shader when a light source is evaluated (which may result in the light source casting shadow rays back).
rays that sample an environment (reflection) map.
is set for displacement shaders.
is set for output shaders.
is set for finalgather rays originating at the final gather point.
is set for lightmap shader in vertex scan mode.
is set for lightmap shader in mesh output mode.
used by rays cast by mi_trace_probe.
is a catch-all for other types of rays.
is a photon emitted from a light source.
is a photon reflected specularly from a surface.
is a photon reflected glossily from a surface.
is a photon reflected diffusely from a surface.
is a photon transmitted specularly through a surface.
is a photon transmitted glossily through a surface.
is a photon transmitted diffusely through a surface.
is a photon transmitted directly (ie., without refraction) through a surface.
is a photon being absorbed.
is a photon scattered in a volume.
is a caustics photon to be cast by a photon emitter shader attached to a light source.
is a global illumination photon to be cast by a photon emitter shader attached to a light source.

The ray type (state→type) can be queried with the following macros:

is true if the raytype is a primary or a transparency ray.
is true if the raytype corresponds to a ray generated at an intersection point.
is true if the raytype is one of the miPHOTON_* rays. This macro can be used to separate the photon tracing part of a shader from the regular ray tracing part.
This flag is set if the current intersection was found by means of the scanline rendering algorithm.
Deprecated Its existence determines which shaders may call which tracing functions. By setting this pointer to 0, the shader can ease these restrictions and call tracing functions that are not normally legal for this type of shader. For details, see the section Shaders and Trace Functions below.
The origin (start point) of the ray in internal space. In the primary material shader, it is set by the last lens shader, or is (0, 0, 0) if there is no lens shader and the default non-orthogonal pinhole camera is used. In all other material shaders, it is the previous intersection point. In light and shadow shaders, it is the origin of the light source. For area lights, it is the point on the virtual surface. If the light source does not have an origin, the value is undefined.
The direction of the ray in internal space. This is basically the normalized difference between point and org, pointing towards the current intersection point (except in the case of directional light sources that have no origin; in this case the light direction is used). Light and non-segmented shadow rays point from the light source to the intersection.
The time of the ray in the shutter interval. If motion blurring is turned off by setting the shutter time to 0.0 (or to the shutter delay value), the time is fixed at the shutter value. Otherwise, it is systematically sampled in the range from the shutter delay to the shutter time.
The volume shader to be applied to the ray. The volume shader is called immediately after the material shader returns, without any change to the state. The volume shader changes the result color of the material shader to take the distance the ray to the material has traveled into account. For primary rays this is the volume of the camera, for reflection and light rays the volume of the parent, and for refraction and transparency rays the refraction_volume of the parent. Note that the mi_trace_refraction and mi_trace_refraction functions copy refraction_volume to volume to ensure that sub-shaders use the volume shader that applies to the interior of the object. Volume shaders are also applied to light rays. This state variable is ignored in autovolume mode.
The active environment shader. For primary rays this is the environment of the camera. For reflection and refraction rays the active shader is taken from the material, if it specifies an environment shader. If it does not, the environment shader defaults to the environment shader in the camera, if present. The purpose of the environment shader is to provide a color if a ray leaves the scene entirely.
The reflection level of the ray. It may range from 0 for primary rays to reflection_depth minus one. The trace_depth imposes another limit: The sum of reflection_level and refraction_level must be one less than trace_depth. A shader may decrement or reset the reflection level to circumvent the restrictions imposed by the trace depth state variables. The level fields are also used during photon tracing, and measure the photon trace depths in this case.
The refraction level of the ray. This is equivalent to the reflection level but applies to refraction and transparency (which is a variation of refraction that does not take the index of refraction into account) rays. A shader may decrement or reset the refraction level to circumvent the restrictions imposed by the trace depth state variables.
This field can be changed by shaders before casting a secondary ray with functions such as mi_trace_reflection. The secondary ray will then obey the changed face flag. The field will be initialized to 0 by mental ray, in which case the face setting from the scene description will take precedence, like render option and face flags on objects and instances. Setting this value to 'f' (front), 'b' (back), or 'a' (both) will overwrite that default value.

Copyright © 1986-2011 by mental images GmbH