2020-03-20 22:23:27 +00:00
|
|
|
#version 460
|
|
|
|
#extension GL_NV_ray_tracing : enable
|
|
|
|
#extension GL_EXT_ray_query : enable
|
|
|
|
|
|
|
|
struct Ray
|
|
|
|
{
|
|
|
|
vec3 pos;
|
|
|
|
float tmin;
|
|
|
|
vec3 dir;
|
|
|
|
float tmax;
|
|
|
|
};
|
|
|
|
|
2020-03-26 22:51:18 +00:00
|
|
|
layout(binding = 0, set = 0) uniform accelerationStructureEXT rtas;
|
2020-03-20 22:23:27 +00:00
|
|
|
layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; };
|
|
|
|
|
|
|
|
uint launchIndex()
|
|
|
|
{
|
|
|
|
return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void doInitialize(rayQueryEXT rayQuery, Ray ray)
|
|
|
|
{
|
2020-03-24 03:09:44 +00:00
|
|
|
rayQueryInitializeEXT(rayQuery, rtas, gl_RayFlagsNoneEXT, gl_RayFlagsCullBackFacingTrianglesEXT, ray.pos, ray.tmin, ray.dir, ray.tmax);
|
2020-03-20 22:23:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
uint index = launchIndex();
|
|
|
|
Ray ray = rays[index];
|
|
|
|
rayQueryEXT rayQuery1;
|
|
|
|
rayQueryEXT rayQuery2;
|
|
|
|
doInitialize(rayQuery1, ray);
|
2020-03-24 03:09:44 +00:00
|
|
|
rayQueryInitializeEXT(rayQuery1, rtas, gl_RayFlagsOpaqueEXT, gl_RayFlagsCullFrontFacingTrianglesEXT, ray.pos, ray.tmin, ray.dir, ray.tmax);
|
2020-03-20 22:23:27 +00:00
|
|
|
doInitialize(rayQuery2, ray);
|
|
|
|
}
|