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?
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.
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
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.