fn miss_main(ray: RayDesc, payload: ptr) { 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(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(0.45, 0.65, 0.95); let zenith = vec3(0.95, 0.85, 0.65); (*payload).color = mix(sky, zenith, t); }