Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit15ce14a4c1

README.md

light_shadows

The shadows the scene's point, spot and area lights cast, as a render-feature compute pass reads them: the same shadow pages the surfaces are shadowed by. A participating medium shadowed through this module is dark from a light wherever a surface standing at that point would be, so a lamp sealed in a box lights none of the air outside it, and a beam ends at the wall it meets.

The pass binds the scene's light buffer and the shadow pool under these names:

# bindings.yaml
  - { name: lights, kind: buffer, access: read, element: vec4<f32> }
  - { name: shadow_pool, kind: texture_depth }
ctx.enqueue {
    kind = "compute", program = prog,
    inputs = { lights = "@scene.lights", shadow_pool = "@scene.shadowPool" },
    ...
}
#include "@builtin::shaderModules.light_shadows"

// 1 where nothing stands between light row `li` and `p`, 0 where an occluder does.
let lit = zero_light_shadow(li, p, footprint);

footprint is the world size of the detail the pass resolves at p, such as a medium's sample spacing or a pixel's width there: the finest shadow mip read is the one whose texel is no smaller. A light that casts no shadow reads 1, and a single-sided rect light closes past the edge of the frustum it casts through, as it does on a surface.

A frame with a pass reading @scene.shadowPool keeps the coarsest page of every map of each casting light whose reach meets the view, so every point a light reaches in that view has a page to be read from. Where a surface asked for a finer page of the same place, that page is read.