Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

fog post-process shader

Depth-keyed distance haze. pp.add(name, "fog", { density = ..., color = { r, g, b } }) registers it, and asset.resolve("@builtin::shaders.post.fog", "shader"):getProperties() reads the knobs below before it is added.

The pass reads the scene depth already drawn at a pixel, turns it into a distance in metres with zero_linear_depth(d, near, far), and mixes the frame toward fogColor by 1 - exp(-distance * density) — an exponential falloff, so density sets how many metres of air it takes to reach the fog colour.

near and far are the planes the frame was projected through. They are what a stored depth is turned back into metres by, so they belong to the camera the scene was drawn with rather than to the look: setting them to something the camera does not use moves every surface's distance and with it the whole haze.

PropertyMeaning
densityFalloff rate. 0 leaves the frame untouched.
fogColorThe colour a fully fogged pixel reaches.
nearThe scene camera's near plane, in metres.
farThe scene camera's far plane, in metres.