Lens effects are distortions of the rendered image achieved by changing the light path through the camera lens. Because lens effects are applied to first-generation rays, there is no loss of quality that would be unavoidable if the distortion were applied in a post-processing stage after rendering.
Lens effects are introduced by specifying one or more lens shaders in the camera statement. If no lens shaders are present, the standard pinhole camera is used. Each lens shader is called with two state variables that specify the ray origin and the ray direction. The lens shader calculates a new origin and a new direction, and casts an eye ray using the mi_trace_eye function. The first lens shader always gets the position of the pinhole camera. All following lens shaders get the origin and direction that the previous lens shader used when calling mi_trace_eye.
Some lens shaders imply ray marching. If lens shaders change the origin or direction of a ray they only work correctly if scanline rendering is turned off. This is normally automated and does not require the user to modify the scene: lens shader declarations should supply this information to inform mental ray that the shader requires ray marching.
Lens shaders that do not change the origin or direction of a ray are also useful, for example to perform color correction or special data collection. Such shaders should not disable scanline mode in their declaration.
Copyright © 1986-2008 by mental images GmbH