• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 460
2#extension GL_EXT_ray_query : require
3
4layout(local_size_x = 16, local_size_y = 8, local_size_z = 1) in;
5
6layout(binding = 0, set = 0) uniform accelerationStructureEXT tlas;
7
8void main()
9{
10  rayQueryEXT rayQuery;
11  rayQueryInitializeEXT(rayQuery,       // Ray query
12                        tlas,           // Top-level acceleration structure
13                        0,              // Ray flags
14                        0xFF,           // 8-bit instance mask
15                        vec3(0),        // Ray origin
16                        0.0,            // Minimum t-value
17                        vec3(1, 0, 0),  // Ray direction
18                        10000.0);       // Maximum t-value
19
20  // yes this is silly, just want to verify the return types
21  bool rq_proceed = rayQueryProceedEXT(rayQuery);
22  while(rq_proceed)
23  {
24    rq_proceed = rayQueryProceedEXT(rayQuery);
25  }
26
27  const uint intersectionType = rayQueryGetIntersectionTypeEXT(rayQuery, true);
28  const float rayTMin = rayQueryGetRayTMinEXT(rayQuery);
29  const uint rayFlags = rayQueryGetRayFlagsEXT(rayQuery);
30  const vec3 worldRayOrigin = rayQueryGetWorldRayOriginEXT(rayQuery);
31  const vec3 worldDirection = rayQueryGetWorldRayDirectionEXT(rayQuery);
32  const float intersectionT = rayQueryGetIntersectionTEXT(rayQuery, true);
33  const int customIndex = rayQueryGetIntersectionInstanceCustomIndexEXT(rayQuery, true);
34  const int instanceId = rayQueryGetIntersectionInstanceIdEXT(rayQuery, true);
35  const uint sbtOffset = rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQuery, true);
36  const int geometryIndex = rayQueryGetIntersectionGeometryIndexEXT(rayQuery, true);
37  const int primitiveIndex = rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true);
38  const vec2 barys = rayQueryGetIntersectionBarycentricsEXT(rayQuery, true);
39  const bool frontface = rayQueryGetIntersectionFrontFaceEXT(rayQuery, true);
40  const bool aabbOpaque = rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQuery);
41  const vec3 objRayDirection = rayQueryGetIntersectionObjectRayDirectionEXT(rayQuery, true);
42  const vec3 objRayOrigin = rayQueryGetIntersectionObjectRayOriginEXT(rayQuery, true);
43  const mat4x3 objToWorld = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, true);
44  const mat4x3 worldToObj = rayQueryGetIntersectionWorldToObjectEXT(rayQuery, true);
45}
46