Renderer · interface

Atmosphere

Atmosphere fields shared by every visible render pass.

Explained in Hello world.

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

Properties

NameTypeDescription
fogColorVec3
fogDensitynumberExtinction per metre at fogBaseY, not at the camera. Air thins with height (see fogHeightFalloff), so the authored number describes the haze where it is thickest and the camera's altitude does the rest.
fogHeightFalloffnumberReciprocal scale height of the haze, per metre: density at height y is fogDensity · exp(−(y − fogBaseY) · fogHeightFalloff). 0 is a uniform medium, which is what an authored vista or an indoor scene wants.
More

Real aerial perspective thins with altitude because there is less air above you, and that is the whole difference between looking along a valley and looking down a mountain. A world with no vertical extent cannot tell the two apart and does not need this; one with 232 m of band very much does.

fogBaseYnumberThe height the haze is thickest at — the sea, usually.
fogModeoptional'exponential' | 'linear'Which curve the haze follows. Absent means exponential, which is the physical one and what every existing world is authored against.
More

linear swaps the medium for a depth ramp between fogNear and fogFar: nothing at all closer than fogNear, the fog colour entirely at fogFar. It exists because that is a distinct look rather than an approximation of this one — a hard clear near field is not something an extinction curve can produce at any density.

fogNearoptionalnumberLinear mode only: where haze begins, and where it is total.
fogFaroptionalnumber
fogStartoptionalnumberThe medium only: how far along the view ray it begins, in metres. Absent or 0 is at the camera, as every world before it was drawn.
More

The air nearer than this is perfectly clear, and what lies beyond is fogged by the air past this point alone — so a faint, bright haze can lie over a distant crowd while the figures a few metres from the camera stay sharp, which no density can do when the medium starts at the eye: there it veils the whole frame, lifting the shadows and draining the colour before it reaches anything far enough to want it. Unlike linear's fogNear, nothing past it is a ramp: it is the same extinction, integrated from further out. What it gives up is the air between the camera and the start, which a real medium has; that is the point of it.

underwaterUnderwaterAtmosphere | null