Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

HeightFog

The scene's atmosphere, as a component. Add it to an entity and the scene gets exponential height fog: density thins with altitude, so a valley pools fog while a hilltop above it clears, and the medium brightens toward the sun.

local id = entity.spawn("atmosphere").id
entity(id).component.add("HeightFog", {
    density = 0.03,
    heightFalloff = 0.12,
    heightRef = 0,
    inscatter = 2.5,
})

Every field is live — editing one in the inspector moves the fog on the next frame, and the values persist with the scene. Setting density to 0 turns fog off while keeping the rest of the settings authored; removing the last one in the scene clears it entirely.

fieldeffect
colorThe colour a fully fogged surface reaches, and so the colour of the far field. Defaults to (0.62, 0.68, 0.78), a daylight grey.
densityExtinction per world unit at heightRef. 0 is no fog.
heightFalloffThinning with altitude, per world unit. 0 gives a distance-only fog.
heightRefThe world-space Y that density describes.
startDistance before fog accumulates, so near geometry stays readable.
inscatterHow far the medium goes toward sunColor at the centre of the sun, in [0, 1]. 0 makes fog directionless.
sunColorThe colour fog takes on when looking into the sun.
inscatterAnisotropyForward-scattering bias in [0, 0.95). Higher tightens the lobe.

The sun the lobe points at is the scene's own, re-read each frame, so fog follows a day/night cycle without being told.

Code that changes fog at runtime can drive the same settings through @builtin::systems.atmosphere.fog instead.