Iray Programmer's Manual

Environment function

The MDL environment function is controlled with the following attribute on the IOptions class:

mi::IRef environment_function

The environment function used for the lookup of the conventional infinite spherical environment, and also for the projections onto the different dome geometries. 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 following two MDL functions are natively supported in the render modes and allow fast updates on parameter changes, while all other MDL functions will be baked into a texture that is then used for environment lookups.

  • base::environment_spherical

  • base::sun_and_sky

Simple transformations on the environment function can be applied using two further attributes on the mi::neuraylib::IOptions class without triggering texture baking:

mi::Float32 environment_function_intensity = 1

A linear scale that is applied to the intensity returned by the environment function.

mi::Float32_3_3 environment_function_orientation = mi::Float32_3_3(1,0,0,0,1,0,0,0,1)

This matrix defines the transform from canonical directions (used for the environment function evaluation) to world space. It can be used to freely rotate the environment. The matrix needs to be orthonormal.

A number of options allow fine-tuning the baking of environment functions to a texture. As before, these options are modeled as attributes on the mi::neuraylib::IOptions class.

mi::Sint32 environment_lighting_resolution = 512

This option controls the number of pixels used for the resolution of the polar angle. The azimuthal resolution is always twice the polar resolution. Higher resolutions result in more detail in the visible environment and sharper shadows if bright details of the environment function are small. However, baking times are increased accordingly.

bool environment_lighting_blur = false

The visual quality of low-resolution environments may sometimes be improved by enabling a small Gaussian filter kernel.