Media

## 6.8 Media

The `media` statement is used to specify particulate matter suspended in a medium such air or water. It can be used to specify smoke, haze, fog, gas, fire, dust etc. Previous versions of POV-Ray had two incompatible systems for generating such effects. One was `halo` for effects enclosed in a transparent or semi-transparent object. The other was `atmosphere` for effects that permeated the entire scene. This duplication of systems was complex and unnecessary. Both `halo` and `atmosphere` have been eliminated. See "Why are Interior and Media Necessary?" for further details on this change. See "Object Media" for details on how to use `media` with objects. See "Atmospheric Media" for details on using `media` for atmospheric effects outside of objects. This section and the sub-sections which follow explains the details of the various `media` options which are useful for either object media or atmospheric media.

Media works by sampling the density of particles at some specified number of points along the ray's path. Sub-samples are also taken until the results reach a specified confidence level. POV-Ray provides three methods of sampling. When used in an object's `interior` statement, sampling only occurs inside the object. When used for atmospheric media, the samples run from the camera location until the ray strikes an object. Therefore for localized effects, it is best to use an enclosing object even though the density pattern might only produce results in a small area whether the media was enclosed or not.

The complete syntax for a `media` statement is as follows:

    MEDIA:
        media { [MEDIA_IDENTIFIER] [MEDIA_ITEMS...] }
    MEDIA_ITEMS:
        method Number | intervals Number | samples Min, Max |
        confidence Value  | variance Value | ratio Value |
        absorption COLOR | emission COLOR | aa_threshold Value |
        aa_level Value |
        scattering {
           Type, COLOR [ eccentricity Value ] [ extinction Value ]
        }  |
        density {
           [DENSITY_IDENTIFIER] [PATTERN_TYPE] [DENSITY_MODIFIER...]
        }   |
        TRANSFORMATIONS
    DENSITY_MODIFIER:
        PATTERN_MODIFIER | DENSITY_LIST | COLOR_LIST |
        color_map { COLOR_MAP_BODY } | colour_map { COLOR_MAP_BODY } |
        density_map { DENSITY_MAP_BODY }

Media default values:

    aa_level     : 4
    aa_threshold : 0.1
    absorption   : <0,0,0>
    confidence   : 0.9
    emission     : <0,0,0>
    intervals    : 10
    method       : 3
    ratio        : 0.9
    samples      : Min 1, Max 1
    variance     : 1/128
    SCATTERING
      COLOR        : <0,0,0>
      eccentricity : 0.0
      extinction   : 1.0

If a media identifier is specified, it must be the first item. All other media items may be specified in any order. All are optional. You may have multiple `density` statements in a single `media` statement. See "Multiple Density vs. Multiple Media" for details. Transformations apply only the `density` statements which have been already specified. Any `density` after a transformation is not affected. If the `media` has no `density` statements and none was specified in any media identifier, then the transformation has no effect. All other media items except for `density` and transformations override default values or any previously set values for this `media` statement.

Note: some media effects depend upon light sources. However the participation of a light source depends upon the `media_interaction` and `media_attenuation` keywords. See "Atmospheric Media Interaction" and "Atmospheric Attenuation" for details.

Note: In the POV-Ray 3.1 documentation it said:

> "Note a strange design side-effect was discovered during testing and it was too difficult to fix. If the enclosing object uses `transmit` rather than `filter` for transparency, then the `media` casts no shadows."

This is not the case anymore in POV-Ray 3.5. Wether you specify `transmit` or `filter` to create a transparent container object, the `media` will always cast a shadow. If a shadow is not desired, use the `no_shadow` keyword for the container object.

In 'Media' ...
6.8.1 | Media Types
6.8.2 | Sampling Parameters & Methods
6.8.3 | Density