Missing documentation found empirically for the aforementioned variables.
We can traverse only one TLAS at at time. While traversing it via
traceRayEXT, we can hit just one BLAS at at a time. Hence, all the *ID
references here are relative to the BLAS we hit (except gl_InstanceID
):
gl_GeometryIndexID
- Geometry index within the BLAS this ray has hit.gl_InstanceID
- BLAS index within the TLAS.gl_PrimitiveID
- Triangle (or other primitive) index within the BLAS.
The gl_GeometryIndexID
and all the mentioned variables are set automatically for the hit shader.
If a BLAS is created with several geomeotries, then the gl_GeometryIndexID
is the zero-based index of the geometry used
during the BLAS creation.
When a TLAS is created from one or many of BLAS instances, the order of these BLAS instances is preserved and when a BLAS is hit,
for the hit shader the gl_InstanceID
is set.
I wish we had those documented better or it was easier to find.