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.
Lens shaders imply ray tracing. If lens shaders change the origin or direction of a ray they only work correctly if scanline rendering is turned off. If scanline is turned on, a warning is printed. Then, the lens shaders must not change the origin or direction of a ray. Lens shaders have no effect on the trace depth limit, eye rays are not counted towards the ray trace depth.