Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1struct Uniforms {
2 view_inv: mat4x4<f32>,
3 proj_inv: mat4x4<f32>,
4};
5@group(0) @binding(0)
6var<uniform> uniforms: Uniforms;
8@group(0) @binding(1)
9var output: texture_storage_2d<rgba8unorm, write>;
11@group(0) @binding(2)
12var acc_struct: acceleration_structure;
14@compute @workgroup_size(8, 8)
15fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
16 let target_size = textureDimensions(output);
18 let pixel_center = vec2<f32>(global_id.xy) + vec2<f32>(0.5);
19 let in_uv = pixel_center / vec2<f32>(target_size.xy);
20 let d = in_uv * 2.0 - 1.0;
22 let origin = (uniforms.view_inv * vec4<f32>(0.0, 0.0, 0.0, 1.0)).xyz;
23 let temp = uniforms.proj_inv * vec4<f32>(d.x, d.y, 1.0, 1.0);
24 let direction = (uniforms.view_inv * vec4<f32>(normalize(temp.xyz), 0.0)).xyz;
26 var rq: ray_query;
27 rayQueryInitialize(&rq, acc_struct, RayDesc(0u, 0xFFu, 0.1, 200.0, origin, direction));
28 rayQueryProceed(&rq);
30 var color = vec4<f32>(0.0, 0.0, 0.0, 1.0);
31 let intersection = rayQueryGetCommittedIntersection(&rq);
32 if intersection.kind != RAY_QUERY_INTERSECTION_NONE {
33 color = vec4<f32>(intersection.barycentrics, 1.0 - intersection.barycentrics.x - intersection.barycentrics.y, 1.0);
34 }
36 textureStore(output, global_id.xy, color);
Contents