-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace.rgen
33 lines (28 loc) · 915 Bytes
/
trace.rgen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#version 460
#extension GL_EXT_ray_tracing: require
layout(set = 0, binding = 0) uniform View {
mat4x4 viewInv;
mat4x4 projInv;
mat4x4 viewProjInv;
};
layout(set = 0, binding = 1) uniform accelerationStructureEXT topLevel;
layout(set = 1, binding = 0, rgba8) uniform writeonly image2D backBuffer;
layout(location = 0) rayPayloadEXT vec3 color;
void main()
{
vec2 fragPos = gl_LaunchIDEXT.xy + 0.5;
vec2 xy = fragPos / gl_LaunchSizeEXT.xy * 2 - 1;
vec4 origin = viewInv * vec4(0, 0, 0, 1);
vec4 dir = viewProjInv * vec4(xy, 0, 1);
float tmin = 0, tmax = 10;
traceRayEXT(topLevel,
gl_RayFlagsOpaqueEXT,
0xFF, // cullMask
0, // sbtRecordOffset
0, // sbtRecordStride
0, // missIndex
origin.xyz, tmin,
normalize(dir.xyz), tmax,
0); // payload
imageStore(backBuffer, ivec2(gl_LaunchIDEXT.xy), vec4(color, 1));
}