Participating media#

In Mitsuba, participating media are used to simulate materials ranging from fog, smoke, and clouds, over translucent materials such as skin or milk, to “fuzzy” structured substances such as woven or knitted cloth. This section describes the two available types of media (homogeneous and heterogeneous). In practice, these will be combined with a phase function.

Participating media are usually attached to shapes in the scene. When a shape marks the transition to a participating medium, it is necessary to provide information about the two media that lie at the interior and exterior of the shape. This informs the renderer about what happens in the region of space surrounding the surface. In many practical use cases it is sufficient to only specify an interior medium and to assume the exterior medium (e.g., air) to not influence the light transport.

<scene version=3.0.0>
    <shape type=".. shape type ..">
        .. shape parameters ..

        <medium name="interior" type="... medium type ...">
            ... medium parameters ...
        </medium>
        <medium name="exterior" type="... medium type ...">
            ... medium parameters ...
        </medium>
        <!-- Alternatively: reference named media that
            have been declared previously
            <ref name="interior" id="myMedium1"/>
            <ref name="exterior" id="myMedium2"/>
        -->
    </shape>
</scene>

When a medium permeates a volume of space (e.g. fog) that includes sensors, it is important to assign the medium to them. This can be done using the referencing mechanism:

<scene version=3.0.0>
    <!-- .. scene contents .. -->

    <medium type="homogeneous" id="fog">
        <!-- .. homogeneous medium parameters .. -->
    </medium>
    <sensor type="perspective">
        <!-- .. perspective camera parameters .. -->
        <!-- Reference the fog medium from within the sensor declaration
            to make it aware that it is embedded inside this medium -->
        <ref id="fog"/>
    </sensor>
</scene>

Homogeneous medium (homogeneous)#

Parameter

Type

Description

Flags

albedo

float, spectrum or volume

Single-scattering albedo of the medium (Default: 0.75).

P,

sigma_t

float or spectrum

Extinction coefficient in inverse scene units (Default: 1).

P,

scale

float

Optional scale factor that will be applied to the extinction parameter. It is provided for convenience when accommodating data based on different units, or to simply tweak the density of the medium. (Default: 1)

P

sample_emitters

boolean

Flag to specify whether shadow rays should be cast from inside the volume (Default: true) If the medium is enclosed in a dielectric boundary, shadow rays are ineffective and turning them off will significantly reduce render time. This can reduce render time up to 50% when rendering objects with subsurface scattering.

(Nested plugin)

phase

A nested phase function that describes the directional scattering properties of the medium. When none is specified, the renderer will automatically use an instance of isotropic.

This class implements a homogeneous participating medium with support for arbitrary phase functions. This medium can be used to model effects such as fog or subsurface scattering.

The medium is parametrized by the single scattering albedo and the extinction coefficient \(\sigma_t\). The extinction coefficient should be provided in inverse scene units. For instance, when a world-space distance of 1 unit corresponds to a meter, the extinction coefficient should have units of inverse meters. For convenience, the scale parameter can be used to correct the units. For instance, when the scene is in meters and the coefficients are in inverse millimeters, set scale to 1000.

../../_images/medium_homogeneous_sss.jpg

Homogeneous medium with constant albedo#

../../_images/medium_homogeneous_sss_textured.jpg

Homogeneous medium with spatially varying albedo#

The homogeneous medium assumes the extinction coefficient to be constant throughout the medium. However, it supports the use of a spatially varying albedo.

<medium id="myMedium" type="homogeneous">
    <rgb name="albedo" value="0.99, 0.9, 0.96"/>
    <float name="sigma_t" value="5"/>

    <!-- The extinction is also allowed to be spectrally varying
         Since RGB values have to be in the [0, 1]
        <rgb name="sigma_t" value="0.5, 0.25, 0.8"/>
    -->

    <!-- A homogeneous medium needs to have a constant extinction,
        but can have a spatially varying albedo:

        <volume name="albedo" type="gridvolume">
            <string name="filename" value="albedo.vol"/>
        </volume>
    -->

    <phase type="hg">
        <float name="g" value="0.7"/>
    </phase>
</medium>

Heterogeneous medium (heterogeneous)#

Parameter

Type

Description

Flags

albedo

float, spectrum or volume

Single-scattering albedo of the medium (Default: 0.75).

P,

sigma_t

float, spectrum or volume

Extinction coefficient in inverse scene units (Default: 1).

P,

scale

float

Optional scale factor that will be applied to the extinction parameter. It is provided for convenience when accommodating data based on different units, or to simply tweak the density of the medium. (Default: 1)

P

sample_emitters

boolean

Flag to specify whether shadow rays should be cast from inside the volume (Default: true) If the medium is enclosed in a dielectric boundary, shadow rays are ineffective and turning them off will significantly reduce render time. This can reduce render time up to 50% when rendering objects with subsurface scattering.

(Nested plugin)

phase

A nested phase function that describes the directional scattering properties of the medium. When none is specified, the renderer will automatically use an instance of isotropic.

This plugin provides a flexible heterogeneous medium implementation, which acquires its data from nested volume instances. These can be constant, use a procedural function, or fetch data from disk, e.g. using a 3D grid.

The medium is parametrized by the single scattering albedo and the extinction coefficient \(\sigma_t\). The extinction coefficient should be provided in inverse scene units. For instance, when a world-space distance of 1 unit corresponds to a meter, the extinction coefficient should have units of inverse meters. For convenience, the scale parameter can be used to correct the units. For instance, when the scene is in meters and the coefficients are in inverse millimeters, set scale to 1000.

Both the albedo and the extinction coefficient can either be constant or textured, and both parameters are allowed to be spectrally varying.

<!-- Declare a heterogeneous participating medium named 'smoke' -->
<medium type="heterogeneous" id="smoke">
    <!-- Acquire extinction values from an external data file -->
    <volume name="sigma_t" type="gridvolume">
        <string name="filename" value="frame_0150.vol"/>
    </volume>

    <!-- The albedo is constant and set to 0.9 -->
    <float name="albedo" value="0.9"/>

    <!-- Use an isotropic phase function -->
    <phase type="isotropic"/>

    <!-- Scale the density values as desired -->
    <float name="scale" value="200"/>
</medium>

<!-- Attach the index-matched medium to a shape in the scene -->
<shape type="obj">
    <!-- Load an OBJ file, which contains a mesh version
         of the axis-aligned box of the volume data file -->
    <string name="filename" value="bounds.obj"/>

    <!-- Reference the medium by ID -->
    <ref name="interior" id="smoke"/>
    <!-- If desired, this shape could also declare
        a BSDF to create an index-mismatched
        transition, e.g.
        <bsdf type="dielectric"/>
    -->
</shape>