16 lines
720 B
WebGPU Shading Language
16 lines
720 B
WebGPU Shading Language
fn miss_main(ray: RayDesc, payload: ptr<function, Payload>) {
|
|
if ((*payload).shadowRay == 1u) {
|
|
// Shadow ray escaped to infinity — the sun is visible from the
|
|
// origin, so the surface there should pick up full direct light.
|
|
// raygen reads color.x as the visibility coefficient.
|
|
(*payload).color = vec3<f32>(1.0);
|
|
return;
|
|
}
|
|
|
|
// Primary miss: cheap two-stop sky gradient. (*payload).hit stays 0
|
|
// so raygen knows to skip the lighting path and just use this color.
|
|
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);
|
|
(*payload).color = mix(sky, zenith, t);
|
|
}
|