height_fog.computeShader
- README.md2.2 KB
- bindings.yaml1.2 KB
- shader.wgsl9.3 KB
This package holds more than this page lists. See all of its files in its world.
README.md
height_fog
Fogs the scene by depth and by height, so the air thickens toward the ground and toward the horizon at once.
Each pixel's view ray is integrated analytically through the exponential height
profile density * exp(-heightFalloff * (y - heightRef)), from the point
start along the ray to the surface (or, for the sky, to the end of the
medium). What is behind is dimmed by exp(-tau) of that optical depth, and the
medium adds the light it scatters toward the camera times 1 - exp(-tau): the
scene's sun (@frame.light) through a Henyey-Greenstein phase function and
the cloud layer's shadow, and the light of the surroundings at the camera (fog_light, written by
height_fog_light), both scaled per channel by the fog's colour. With every
light dark the fog adds nothing.
The cloud layer's shadow (cloud_shadow) is read at four points along the
ray, each the middle of an equal share of the light the fog scatters toward the
camera (the optical depth inverted along the ray), and their mean scales the
sun's share: fog under a cloud takes less of the sun, and the sun reaches the
fog through the gaps between clouds. With no cloud layer casting a shadow the
mean is 1 and no point is read.
heightfog_pass names which pixels a dispatch fogs: [0].x 1 fogs the sky the
opaque scene left (a pixel at the far end of @scene.depth) and passes every
surface through, 0 fogs the surfaces the frame's depth holds and passes the sky
through. The feature runs the sky dispatch ahead of the transparent phase and
the surface dispatch after it.
Includes
@builtin::shaderModules.surface_flags@builtin::shaderModules.frame_light@builtin::systems.volumetrics.shaders.cloud_shadow
Bindings
| name | kind |
|---|---|
scene_color | texture2d |
scene_depth | texture_depth |
scene_normal | texture2d |
frame_cam | buffer, read vec4<f32> |
scene_light | buffer, read vec4<f32> |
fog_light | texture2d |
heightfog_params | buffer, read vec4<f32> |
heightfog_pass | buffer, read vec4<f32> |
cloud_shadow_map | texture2d |
cloud_shadow_smp | sampler |
cloud_shadow | buffer, read vec4<f32> |
fog_out | storage2d (rgba16f) |