Crafter.Graphics/examples/VulkanTriangle/closesthit.wgsl

15 lines
546 B
WebGPU Shading Language
Raw Normal View History

// Payload declared here so the WGSL assembler sees it before the wfPayload
// binding, the SHADE dispatch, and the raygen source.
//
// Wavefront model: closesthit_main runs in SHADE and accumulates the
// pixel's color directly (rtAccumulate) instead of writing a payload that
// raygen reads back.
2026-05-18 18:43:30 +02:00
struct Payload {
color: vec3<f32>,
};
fn closesthit_main(ray: RayDesc, hit: HitInfo, payload: ptr<function, Payload>) {
let bary = vec3<f32>(1.0 - hit.attribs.x - hit.attribs.y, hit.attribs.x, hit.attribs.y);
rtAccumulate(bary);
2026-05-18 18:43:30 +02:00
}