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.
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-2008 by mental images GmbH