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 |
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, 2015 NVIDIA ARC GmbH. All rights reserved.