Iray Programmer's Manual


The camera holds lens settings to simulate depth-of-field effects. This is controlled with the following attributes on the ICamera class, with all values being set in world scales and so must be adjusted according to the scene dimensions.

mi::Float32 mip_lens_radius = 0.0

Controls the radius of the lens.

mi::Float32 mip_lens_thickness = 0.0

Controls the thickness of the lens.

mi::Float32 mip_lens_focus = 2.0

Controls the focal distance to which the camera is adjusted.

mi::Float32 mip_lens_shift_x = 0.0

Controls the horizontal lens shift.

mi::Float32 mip_lens_shift_y = 0.0

Controls the vertical lens shift.

const char* mip_lens_distortion_type = "none"

Controls the lens distortion model. The radial distortion models define the relationship between the undistorted radial pixel coordinate ru and the distorted radial pixel coordinate rd.

The supported modes are:

  • "spherical" — Conventional spherical camera mapping.

  • "poly3" — Third order radial distortion model: rd = ru * (1 - k1 + k1 * ru2)

  • "inv_poly3" — Third order inverse radial distortion model: ru = rd * (1 - k1 + k1 * rd2)

  • "poly5" — Fifth order radial distortion model: rd = ru * (1 + k1 * ru2 + k2 * ru4)

  • "inv_poly5" — Fifth order inverse radial distortion model: ru = rd * (1 + k1 * rd2 + k2 * rd4)

  • "ptlens" — Fourth order radial distortion model: rd = ru * (1 - k1 - k2 - k3 + k1 * ru + k2 * ru2 + k3 * ru3)

  • "inv_ptlens" — Fourth order inverse radial distortion model: ru = rd * (1 - k1 - k2 - k3 + k1 * rd + k2 * rd2 + k3 * rd3)

mi::Float32_3 mip_lens_distortion_params = mi::Float32_3(0,0,0)

Controls the parameters k1, k2 and k3 in the radial distortion models.

mi::Float32 mip_lens_distortion_scale = 1.0

Controls the relative scale of the lens distortion.

An aperture function is used to lookup the lens aperture tint. The aperture function is evaluated over a square lens with the radius specified by the mip_lens_radius option. The 2D lens coordinates are passed to the function as the first texture space in the rendering state, ranging from 0 to 1. All MDL functions are supported whose return type is either color or base::texture_return. In the latter case, only the tint field is used and mono filed is ignored.

The aperture function is controlled with the following methods on the mi::neuraylib::ICamera class.

Method signature Description
mi::Sint32 mi::neuraylib::ICamera::set_aperture_function(
    const char* name)

const char* mi::neuraylib::ICamera::get_aperture_function()

Defines the texture through a texture lookup function represented as a DB element of type mi::neuraylib::IMdl_function_call. There is no aperture shader by default, in which case the aperture is not tinted.