This table lists all state variables that remain unchanged
for the duration of a frame.
||shader interface version
||tag of camera instance
||general rendering options
The version number of the interface and the state structure.
Useful to check if the version is compatible with the shader.
Version 2 stands for mental ray version 2.0 and later.
The camera instance is a data structure in the mental ray
database that contains transformation information about the camera.
Like all other tags in the state, a pointer to that data structure
can be obtained by calling mi_db_access with the tag as the
only argument. This function returns a void pointer to the accessed
data structure. After the pointer is no longer used, the pointer
must be "returned" by calling mi_db_unpin with it. Failure
to do so will abort rendering.
The camera data structure pointed to by camera has the following
fields. None of these may be written to from a shader.
||focal length of the camera
||aperture of the camera
||aspect ratio y ⁄ x
||Z clipping distances
||image width in pixels
||image height in pixels
||left image margin
||bottom image margin
||right image margin
||top image margin
||camera volume (atmosphere)
||camera environment shader
||lens shader or lens shader list
||output shader or output shader list
||frame time in seconds
||0: frame, 1: even field, 2: odd field
||x offset of image in pixels
||y offset of image in pixels
||user data scene element, or 0
This flag is miTRUE if the renderer is in orthographic
mode, and miFALSE if it is in perspective mode.
The focal length of the camera (the distance from the origin in
camera space to the viewing plane that the image pixels are mapped
The aperture of the camera (the width of the viewing plane in
The aspect ratio (the ratio of the width and height of the
viewing plane in camera space).
This data structure has two members, min and max,
that specify the hither and yon clipping planes in camera space for
scanline rendering. Objects will be clipped if their Z coordinate
in camera space is less than -max or greater than -min.
The x resolution of the image in pixels.
The y resolution of the image in pixels.
The window specifies the lower left and the upper right pixel of
the sub-region of the image to be rendered. If xl and
yl are 0 and xh and yh match or exceed the
resolution minus one, the entire image is rendered. The window is
clipped to the resolution. Pixels outside the window are set to black.
The global volume (atmosphere) shader from the camera that is
used for attenuating rays outside of objects, such as the primary
ray from the camera to the first object intersection. Material
shaders inherit this volume shader because the volume
state variable defaults to the camera volume, but shaders may
override the volume. See below.
The environment (reflection
map) shader of the camera. It is used to assign a color to
primary eye rays that leave the scene without ever intersecting an
object. Material shaders that do not define their own environment
shaders for evaluation of local reflection maps inherit the camera
environment shader. Reflection maps give the illusion of true
raytraced reflections by looking up a texture based on the
The list of lenses applied to the standard
pinhole camera. Each lens shader in
this list is called when a primary ray leaves the camera.
The list of output shaders and file outputs attached to the
camera. File outputs are encoded in special miFunction
data structures that contain a file name and various miscellaneous
data instead of a shader reference.
The list of pass rendering statements.
The current frame number.
In field mode, this is the field number, two successive frames
rendered by mental ray are combined into a single output frame by
an output shader. In field mode, the odd frame is the first frame
and the even frame is the second.
The current frame number,
expressed as a time in seconds. The relation between frame
and frame_time depends on the frame rate. Both numbers are
taken verbatim from the input scene, mental ray does not change or
verify either number. If the frame time is omitted in the .mi file,
it is set to 0.0.
The X offset of the rendered image. The default value is 0.0
which means that the image will be centered on the camera's axis.
The Y offset of the rendered image. The default value is 0.0
which means that the image will be centered on the camera's
User data blocks are independent named toplevel scene entities
that hold structured or unstructured data of any kind. Structured
data is declared much like shader parameters, while unstructured
data is a raw byte stream with a fixed size. User data is useful
for large amounts of shared scene data.
The options field in the state contains all rendering
options specified in the scene, potentially overridden from the
command line. Since the number of options is very large, and since
they are rarely used in a shader, the description can be found near
the end of this section, on page
Copyright © 1986, 2013