The graphics device.
The color of the ambient in-scattered light, which keeps the fog in shadowed areas visible. Defaults to white.
The intensity of the ambient in-scattered light. Defaults to 0.02.
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.
The camera frame the effect is registered with, or null.
The fog density at the base height. Defaults to 0.01.
The graphics device.
Whether the volumetric fog is enabled. Defaults to false.
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.
The world space height at which the fog density starts to fall off. Below it the density is constant. Defaults to 0.
The exponential falloff of the fog density with height above the base height. Value of 0 makes the fog uniform. Defaults to 0.05.
The intensity of the light scattering. Defaults to 1.
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.
The intensity of the light scattering of the local lights. Defaults to 1.
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.
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.
The number of raymarching steps taken inside the volume of each local light, 2-64 range. Defaults to 12.
The maximum world space distance the fog is raymarched to. Defaults to 300.
The resolution scale of the fog texture relative to the scene render target, 0.25-1 range. Defaults to 0.5.
The number of raymarching steps, 4-128 range. Higher values improve the quality at a higher performance cost. Defaults to 24.
The albedo of the fog. Defaults to white.
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.
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.
Gets the names of the debug views the chunk provides.
Gets the define set on the compose shader while the effect is active: the id in upper snake
case, colorEnhance giving COLOR_ENHANCE.
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.
Gets the GLSL source of the compose chunk, or null when the effect has none.
Gets the identifier of the effect.
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.
Gets the compose slot the entry function is called at, or null for an effect that does not take part in the composition.
Gets the WGSL source of the compose chunk, or null when the effect has none.
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.
The values of this frame.
Returns the compose chunk source for a shader language.
SHADERLANGUAGE_GLSL or SHADERLANGUAGE_WGSL.
The source, or null when the effect has no chunk.
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.
The define name.
The value.
Sets the value of a uniform the effect's shader chunk reads. Like a material parameter, the value is stored by reference, so an array or a texture can be updated in place. Set the values in CameraFrameEffect#update, or in CameraFrameEffect#frameUpdate for a value which changes every frame.
The name of the uniform, as declared in the chunk.
The value.
Applies the effect's parameters. Called by CameraFrame#update while the effect is active: set the uniform values with CameraFrameEffect#setUniform here, and the defines which depend on the parameters. Everything it sets is what the frames rendered until the next update use.
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.