Renderer · interface

GlobalMediumOptions

How thick the air is, this frame.

Explained in Hello world.

interface GlobalMediumOptions
import type { GlobalMediumOptions } from '@driftengine/core';

In depth

A per-frame dial and not a quality setting, in the split renderQuality.ts draws for depth of field: what a device can afford is globalMediumSteps, and what the weather is doing is this. A game walks into a fog bank; a profile decides how expensive being in one is allowed to be.

Properties

NameTypeDescription
densityreadonlynumberExtinction per metre. 0 is off, and off is free — no target is allocated, no pass is built and the composite is skipped, so a game that never sets this pays nothing at all.
More

As a scale: 0.02 leaves a wall at 50 m about a third obscured, 0.1 is thick weather, and above about 0.5 nothing is visible past a room.

albedoreadonlynumber | Vec3How much of what the medium takes out of a ray comes back as light rather than as heat, 0 to 1, or a colour, a share a channel.
More

Near 1 for water droplets, which is fog, cloud and steam; lower for smoke, which is soot and absorbs most of what it intercepts. It is the difference between a white fog that a torch lights up and a black smoke that swallows the same torch. A colour is a medium that keeps more of one light than another: a faintly blue haze returns the sky's blue a little more readily.

anisotropyreadonlynumberHenyey-Greenstein anisotropy, -1 back to 1 forward. 0 is isotropic.
More

This is the term that makes a medium read as weather rather than as a grey wash. Real haze is strongly forward-scattering, which is why the air around a low sun glows and the same air behind the viewer does not. Around 0.6 for atmospheric haze; 0 for a medium with nothing directional about it at all.

maxDistancereadonlynumberWhere the medium ends, in metres: past it the air neither scatters nor absorbs.
More

This said extinction went on past it, and the march never did that: it integrates from the eye to here or to the surface, whichever is nearer, and nothing after. Which is what a medium standing for the near part of the environment's haze wants: the haze takes the rest of the ray when its fogStart is this distance, and the two never lay one stretch of air twice. What it gives up is a medium of its own beyond the reach, which the haze has to be.

heightFalloffreadonlyoptionalnumberReciprocal scale height, per metre: density is the extinction at baseY, thinning above it as the haze does (Atmosphere.fogHeightFalloff). Absent or 0, the medium is as thick everywhere, as it always was.
baseYreadonlyoptionalnumberThe height density is measured at. Default 0.
layer2readonlyoptionalFogLayer | nullA second layer, summed with the first, its own density at its own height thinning by its own falloff: Atmosphere.fogLayer2's shape, so a medium standing for the near part of a two-layer haze can be that haze.
sunScatterreadonlyoptionalnumberHow strongly the sun scatters in it, as a share of how strongly it lights a surface. Default 1.
skyScatterreadonlyoptionalnumberThe same for the sky's fill, which lights a shadowed medium from every side. Default 1.
skyFillreadonlyoptionalreadonly [number, number, number] | nullThe sky's fill the medium scatters, a colour of its own in the units of Environment.ambient, which skyScatter then scales. Absent or null, the frame's ambient, as it always was. For a scene whose surfaces are lit by more than its flat ambient, a sky's cubemap, probes and a bake, which keeps that ambient for what falls outside them: the ambient is then the wrong colour for the sky's light in the air, and setting it to the right one would relight those surfaces too. What it gives up is the sky's direction, as the ambient does: one colour from every side.
lampScatterreadonlyoptionalnumberThe same for the lamps, each through its own shadow and times its own lightMediumScatter. Default 0: a medium was the sun's and the sky's until there was this, and a scene that never asks keeps that picture and that cost. The lamps are the lit stage's per-pixel set, shaped by their cones; a photometric profile and a cookie shape the pool on a surface and not the shaft in the air.