0
$\begingroup$

I am working on the port of a demo from DXR to Vulkan Ray Tracing extension using GLSL. In DXR/HLSL space, there are RayTMin() and RayTCurrent() functions to retrieve the starting and the current end point of the ray (Origin + (Direction * RayTMin) and Origin + (Direction * RayTCurrent), respectively). In Vulkan RT/GLSL space, one specifies the tMin and tMax values in the traceRayEXT(...) call, but how does one retrieve the "current t" and "t min" values in an intersection shader?

$\endgroup$

2 Answers 2

1
$\begingroup$

According to this document, one should be able to extract those values through gl_RayTminEXT and gl_RayTmaxEXT GLSL built-ins for intersection shader.

Further comments are welcome.

$\endgroup$
1
$\begingroup$

As I understand GLSL_EXT_ray_tracing.txt, gl_RayTmaxEXT contains the current t in intersection shaders, due to the following pieces of information given in GLSL_EXT_ray_tracing.txt:

 In the intersection language, built-in variables are declared as follows

    ...

    // Ray parameters
    in          float  gl_RayTminEXT;
    in volatile float  gl_RayTmaxEXT;
    in          uint   gl_IncomingRayFlagsEXT;

    ...

=> due to the volatile declaration of gl_RayTmaxEXT.

Also the description of bool reportIntersectionEXT(float hitT, uint hitKind); remarks that gl_RayTmaxEXT is not constant:

If the intersection is not ignored in the any-hit shader, <hitT> is committed as the new gl_RayTmaxEXT value of the current ray, is committed as the new value for gl_HitKindEXT, and true is returned.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.