mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-08 11:30:06 +00:00
36 lines
978 B
Plaintext
36 lines
978 B
Plaintext
#version 460
|
|
#extension GL_NV_ray_tracing : enable
|
|
#extension GL_EXT_ray_query : enable
|
|
|
|
struct Ray
|
|
{
|
|
vec3 pos;
|
|
float tmin;
|
|
vec3 dir;
|
|
float tmax;
|
|
};
|
|
|
|
layout(binding = 0, set = 0) uniform accelerationStructureEXT rtas;
|
|
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)
|
|
{
|
|
rayQueryInitializeEXT(rayQuery, rtas, gl_RayFlagsNoneEXT, gl_RayFlagsCullBackFacingTrianglesEXT, ray.pos, ray.tmin, ray.dir, ray.tmax);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
uint index = launchIndex();
|
|
Ray ray = rays[index];
|
|
rayQueryEXT rayQuery1;
|
|
rayQueryEXT rayQuery2;
|
|
doInitialize(rayQuery1, ray);
|
|
rayQueryInitializeEXT(rayQuery1, rtas, gl_RayFlagsOpaqueEXT, gl_RayFlagsCullFrontFacingTrianglesEXT, ray.pos, ray.tmin, ray.dir, ray.tmax);
|
|
doInitialize(rayQuery2, ray);
|
|
}
|