Engine API Reference - v2.24.0-beta.10
    Preparing search index...

    Class VolumetricFogEffect

    The volumetric fog effect, a raymarched height fog lit by a directional light. The fog samples the light's cascaded shadow map along each view ray, forming visible shafts of light. The raymarch runs at a reduced resolution and is blended into the scene before TAA, so when TAA is enabled, its noise is temporally resolved to a smooth result. Optionally the clustered omni and spot lights scatter light in the fog as well, see VolumetricFogEffect#localOmniLights and VolumetricFogEffect#localSpotLights.

    The fog is rendered by passes the effect owns, from the scene depth, into the scene. It is only supported on perspective cameras.

    Every CameraFrame constructs and registers one, available as CameraFrame#volumetricFog.

    Hierarchy (View Summary)

    Index
    ambientColor: Color = ...

    The color of the ambient in-scattered light, which keeps the fog in shadowed areas visible. Defaults to white.

    ambientIntensity: number = 0.02

    The intensity of the ambient in-scattered light. Defaults to 0.02.

    anisotropy: number = 0.6

    The anisotropy of the scattering, 0-0.95 range. Larger values scatter more light forward, making the fog brighter when looking towards the light. Defaults to 0.6.

    cameraFrame: CameraFrame | null = null

    The camera frame the effect is registered with, or null.

    density: number = 0.01

    The fog density at the base height. Defaults to 0.01.

    The graphics device.

    enabled: boolean = false

    Whether the volumetric fog is enabled. Defaults to false.

    extinction: number = 1

    A scale of how quickly the fog absorbs the light passing through it, without affecting how much light it scatters. A value of 1 is physically consistent, where the fog absorbs as much as it scatters, and distant fog and light shafts fade out exponentially with the density. Lower values keep them visible over a longer distance while the fog itself stays as bright, which is not physically correct but is often preferable. Defaults to 1.

    heightBase: number = 0

    The world space height at which the fog density starts to fall off. Below it the density is constant. Defaults to 0.

    heightFalloff: number = 0.05

    The exponential falloff of the fog density with height above the base height. Value of 0 makes the fog uniform. Defaults to 0.05.

    intensity: number = 1

    The intensity of the light scattering. Defaults to 1.

    light: LightComponent | null = null

    The directional light providing the scattered light, or null when the fog is lit by the local lights and the ambient term only. When a light of a type other than directional is assigned, the effect is disabled. Defaults to null.

    localIntensity: number = 1

    The intensity of the light scattering of the local lights. Defaults to 1.

    localOmniLights: boolean = false

    Whether the clustered omni lights scatter light in the fog. Each light adds a raymarch over the part of the view rays inside its volume, sampling the shadow and the cookie atlas of the clustered lighting, and so the cost scales with the screen space size of the light volumes. As an omni light fills its whole bounding sphere, its volume is typically much larger on the screen than the volume of a spot light. Requires clustered lighting, which is enabled by default. Individual lights can scatter more or less light using LightComponent#volumetricScattering. Defaults to false.

    localSpotLights: boolean = false

    Whether the clustered spot lights scatter light in the fog, forming visible beams. See VolumetricFogEffect#localOmniLights for details, both types are rendered the same way and share the VolumetricFogEffect#localIntensity and VolumetricFogEffect#localSteps settings. Defaults to false.

    localSteps: number = 12

    The number of raymarching steps taken inside the volume of each local light, 2-64 range. Defaults to 12.

    maxDistance: number = 300

    The maximum world space distance the fog is raymarched to. Defaults to 300.

    scale: number = 0.5

    The resolution scale of the fog texture relative to the scene render target, 0.25-1 range. Defaults to 0.5.

    steps: number = 24

    The number of raymarching steps, 4-128 range. Higher values improve the quality at a higher performance cost. Defaults to 24.

    tint: Color = ...

    The albedo of the fog. Defaults to white.

    • get active(): boolean

      Gets whether the effect contributes to the frame: it is enabled, it has a light source - the directional light or the local lights - and the camera is a perspective camera.

      Returns boolean

    • get chunkName(): string

      Gets the name the compose chunk can be overridden under in ShaderChunks, the same way as the built-in chunks. Derived from the id as compose<Id>PS unless given.

      Returns string

    • get defineName(): string

      Gets the define set on the compose shader while the effect is active: the id in upper snake case, colorEnhance giving COLOR_ENHANCE.

      Returns string

    • get entryPoint(): string

      Gets the name of the function the composition calls at the effect's slot. Derived from the id as apply<Id> unless given. The signature depends on the slot: colour slots take (vec3 color, vec2 uv) and return the colour, COMPOSESLOT_SCENE takes and returns a vec4.

      Returns string

    • get requires(): string[]

      Gets the frame resources the effect needs, the FRAMERESOURCE_* constants - for its passes, or for its compose chunk, such as the scene depth. The camera frame provides them while the effect is active. Requirements which depend on the device are computed when constructing the effect; override this as a getter when they depend on a parameter, and the camera frame provides what it returns from the next CameraFrame#update.

      Returns string[]

    • get slot(): string | null

      Gets the compose slot the entry function is called at, or null for an effect that does not take part in the composition.

      Returns string | null

    • Destroys the effect, removing it from its camera frame if it is still registered and releasing everything it owns, the passes it created included. Subclasses which create resources in their constructor release them in an override, calling super.destroy(). The removal takes effect for the frames rendered after the next CameraFrame#update, which is due before the next frame renders.

      Returns void

    • Sets a define on the compose shader. The define persists until changed, so fixed defines can be set once in the constructor and those depending on the parameters from CameraFrameEffect#update. A value of false, null or undefined removes it. Changing a define rebuilds the compose shader.

      Parameters

      • name: string

        The define name.

      • value: any

        The value.

      Returns void