Crafter.Graphics/examples/Sponza/miss.wgsl
catbot 376e66aeed WebGPU RT: port Sponza to wavefront (shadow ray in SHADE)
Restructure Sponza for the wavefront model: raygen emits the primary ray;
closesthit (in SHADE) gathers albedo/normal, accumulates ambient, and
emits a shadow ray carrying the pending direct term; miss adds the sky
(primary) or the direct term (shadow miss). resolve.wgsl applies the same
Reinhard+gamma the megakernel raygen did inline. User bindings moved to
group 3 (groups 0..2 reserved). RTPass maxDepth=2.

Renders the atrium correctly through the wavefront pipeline (textures,
two-sided shading, sun+ambient, shadows, tonemap).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 20:16:04 +00:00

12 lines
499 B
WebGPU Shading Language

// Sponza miss (runs in SHADE). Primary miss → two-stop sky gradient.
// Shadow miss → the sun is unoccluded, so add the pending direct term.
fn miss_main(ray: RayDesc, payload: ptr<function, Payload>) {
if ((*payload).shadowRay == 1u) {
rtAccumulate((*payload).color);
return;
}
let t = clamp(ray.direction.y * 0.5 + 0.5, 0.0, 1.0);
let sky = vec3<f32>(0.45, 0.65, 0.95);
let zenith = vec3<f32>(0.95, 0.85, 0.65);
rtAccumulate(mix(sky, zenith, t));
}