2 #extension GL_NV_ray_tracing : enable
3 #extension GL_EXT_ray_query : enable
13 layout(std430, set = 0, binding = 0) buffer Log
19 layout(binding = 1, set = 0) uniform accelerationStructureEXT rtas;
20 layout(std430, set = 0, binding = 2) buffer Rays { Ray rays[]; };
30 return gl_LaunchIDNV.z*gl_LaunchSizeNV.x*gl_LaunchSizeNV.y + gl_LaunchIDNV.y*gl_LaunchSizeNV.x + gl_LaunchIDNV.x;
35 uint index = launchIndex();
36 Ray ray = rays[index];
39 bool committed_true = true;
40 bool committed_false = false;
42 rayQueryInitializeEXT(rayQuery, rtas, gl_RayFlagsOpaqueEXT, gl_RayFlagsCullBackFacingTrianglesEXT, ray.pos, ray.tmin, ray.dir, ray.tmax);
43 while (rayQueryProceedEXT(rayQuery))
48 uint candidateType = rayQueryGetIntersectionTypeEXT(rayQuery, committed_false);
49 if (candidateType == gl_RayQueryCandidateIntersectionTriangleEXT)
51 rayQueryTerminateEXT(rayQuery);
53 mat_o2w = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, committed_false);
54 mat_w2o = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, committed_false);
56 rayQueryConfirmIntersectionEXT(rayQuery);
58 if (rayQueryGetIntersectionFrontFaceEXT(rayQuery, committed_true))
62 if (rayQueryGetIntersectionBarycentricsEXT(rayQuery, committed_true).x == 0)
66 if (rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, committed_true) > 0)
70 if (rayQueryGetIntersectionInstanceIdEXT(rayQuery, committed_true) > 0)
74 if (rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, committed_true).x > 0)
78 if (rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, committed_true).x > 0)
82 if (rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, committed_true) > 0)
86 if (rayQueryGetIntersectionTEXT(rayQuery, committed_true) > 0.f)
90 if (rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, committed_true) > 0)
97 uint committedStatus = rayQueryGetIntersectionTypeEXT(rayQuery, committed_true);
98 if (committedStatus == gl_RayQueryCommittedIntersectionGeneratedEXT)
100 if (rayQueryGetIntersectionGeometryIndexEXT(rayQuery, committed_true) > 0)