Any positional and other spatial information in the state is given in a certain coordinate system, often referred to as coordinate space. The following coordinate spaces are supported by mental ray.
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 a family of 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 vector transformations are similar to regular 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. The function mi_vector_transform_T transforms with the transpose of the matrix and can be used for the transformation of normals.
Copyright © 1986, 2013 NVIDIA Corporation