fog.shader
- .metadata17 B
- README.md1.0 KB
- properties.yaml146 B
- shader.wgsl1.0 KB
This package holds more than this page lists. See all of its files in its world.
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_through(d, engine.view_proj, zero_camera_position()),
which reads the near and far planes and the kind of projection from the camera the
frame was drawn with, 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.
A surface fogs by its distance along the camera's view axis whatever near and far planes the camera draws with, and the sky fogs as a surface at the camera's far plane.
| Property | Meaning |
|---|---|
density | Falloff rate. 0 leaves the frame untouched. |
fogColor | The colour a fully fogged pixel reaches. |