Builtin Library
- ..
- .metadata17 B
- README.md1.1 KB
- properties.yaml433 B
- shader.wgsl924 B
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.
| Property | Meaning |
|---|---|
density | Falloff rate. 0 leaves the frame untouched. |
fogColor | The colour a fully fogged pixel reaches. |
near | The scene camera's near plane, in metres. |
far | The scene camera's far plane, in metres. |