• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 460
2#extension GL_NV_ray_tracing : enable
3#extension GL_EXT_ray_query : enable
4
5struct Ray
6{
7    vec3 pos;
8    float tmin;
9    vec3 dir;
10    float tmax;
11};
12
13layout(binding = 0, set = 0) uniform accelerationStructureEXT rtas;
14layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; };
15
16uint launchIndex()
17{
18    return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x;
19}
20
21void doInitialize(rayQueryEXT rayQuery, Ray ray)
22{
23    rayQueryInitializeEXT(rayQuery, rtas, gl_RayFlagsNoneEXT, gl_RayFlagsCullBackFacingTrianglesEXT, ray.pos, ray.tmin, ray.dir, ray.tmax);
24}
25
26void main()
27{
28    uint index = launchIndex();
29    Ray ray = rays[index];
30    rayQueryEXT rayQuery1;
31    rayQueryEXT rayQuery2;
32    doInitialize(rayQuery1, ray);
33    rayQueryInitializeEXT(rayQuery1, rtas, gl_RayFlagsOpaqueEXT, gl_RayFlagsCullFrontFacingTrianglesEXT, ray.pos, ray.tmin, ray.dir, ray.tmax);
34    doInitialize(rayQuery2, ray);
35}
36