*Internal space* is the coordinate
system mental ray uses to present intersection points and other
points and vectors to shaders. All points and vectors in the state
are presented in internal space, namely `org`, `dir`,
`point`, `normal`, `normal_geom`,
`motion` and `derivs`, *except* `bump`
basis vectors which are in object
space. The actual meaning of internal space is left undefined,
it varies between different versions of mental ray and depends on
the `space` given in the `options` block of the
scene. **A shader must not assume that internal space is identical
to world space**, even though this is true in most scenes.

*World space*- is the coordinate system in which modeling and animation takes place.
*Object space*- is a coordinate system relative to the object's origin. The modeler that created the scene defines the object's origin. Most translators use the center of the bounding box of the object as the object origin.
*Camera space*- is a coordinate system in which the camera is at the coordinate
origin
*(0, 0, 0)*with an*up*vector of*(0, 1, 0)*and looking down the negative Z axis. *Raster space*- is a two-dimensional pixel location on the screen bounded by
*(0, 0)*in the lower left corner of the image, and the rendered image resolution. The center of the pixel in the lower left corner of raster space has the coordinates*(0.5, 0.5)*. *Screen space*- is defined such that
*(-1, -1/a)*is in the lower left corner of the screen and*(1, 1/a)*is in the upper right, where*a*is the aspect ratio of the screen (the relation between its width and height).

Most shaders never need to transform between spaces. Texture
shaders frequently need to operate in object space. For example, in order to
apply bump basis vectors to `state→normal`

, the
normal must be transformed to object space before the bump basis
vectors are applied, and back to internal space before the result
is passed to any mental ray function such as *mi_trace_reflection*.
mental ray offers 18 functions to convert points, vectors and
normals between coordinate spaces:

function |
operation |
---|---|

mi_point_to_world(s,p_r,p) |
internal point to world space |

mi_point_to_camera(s,p_r,p) |
internal point to camera space |

mi_point_to_object(s,p_r,p) |
internal point to object space |

mi_point_from_world(s,p_r,p) |
world point to internal space |

mi_point_from_camera(s,p_r,p) |
camera point to internal space |

mi_point_from_object(s,p_r,p) |
object point to internal space |

mi_vector_to_world(s,v_r,v) |
internal vector to world space |

mi_vector_to_camera(s,v_r,v) |
internal vector to camera space |

mi_vector_to_object(s,v_r,v) |
internal vector to object space |

mi_vector_from_world(s,v_r,v) |
world vector to internal space |

mi_vector_from_camera(s,v_r,v) |
camera vector to internal space |

mi_vector_from_object(s,v_r,v) |
object vector to internal space |

mi_normal_to_world(s,v_r,v) |
internal normal to world space |

mi_normal_to_camera(s,v_r,v) |
internal normal to camera space |

mi_normal_to_object(s,v_r,v) |
internal normal to object space |

mi_normal_from_world(s,v_r,v) |
world normal to internal space |

mi_normal_from_camera(s,v_r,v) |
camera normal to internal space |

mi_normal_from_object(s,v_r,v) |
object normal to internal space |

Point and vector transformations are similar, except that the vector versions ignore the translation part of the matrix. Normal transformations are similar to vector transformations, except that the transpose of the inverse transformation matrix is used. In this way it is ensured that if a vector and a normal are orthogonal in one coordinate system they remain orthogonal after they have been transformed to a different coordinate system. This holds for arbitrary, not necessarily orthogonal transformations.

The length of vectors is preserved only if the transformation
matrix does not scale. The *mi_point_transform* and *mi_vector_transform* functions are
also available to transform points and vectors between arbitrary
coordinate systems given by a transformation matrix. *mi_vector_transform_T* transforms
with the transpose of the matrix and can be used for the
transformation of normals.

Copyright © 1986-2010 by mental images GmbH