nvpro-samples / vk_raytracing_tutorial_KHR

Ray tracing examples and tutorials using VK_KHR_ray_tracing
Apache License 2.0
1.34k stars 142 forks source link

gl_InstanceId and gl_InstanceCustomIndex #57

Closed FuXiii closed 1 year ago

FuXiii commented 1 year ago

In NVIDIA Vulkan Ray Tracing Tutorial section 5.2 Top-Level Acceleration Structure

image

I could not found the definition about gl_InstanceId and gl_InstanceCustomIndex . I only can find some describe about gl_InstanceID and gl_InstanceIndex in Vulkan Specification

image

mklefrancois commented 1 year ago

See the ray tracing specification.

The definition about gl_InstanceCustomIndexEXT can be found at line 728 and gl_InstanceID at line 745

FuXiii commented 1 year ago

Thanks! (๑•̀ㅂ•́)و✧

FuXiii commented 1 year ago

as gl_InstanceId specifies the index of the instance that intersects the current ray, which is in this case the same value as i.

What is the i ? (=′∇`=)

Is the i means the instances index in shader? such like:

layout(set = 1, binding = eObjDescs, scalar) buffer objDesc_ {ObjDesc i[];} objDesc;
NBickford-NV commented 1 year ago

I believe i here is intended to be ObjInstance::objIndex (i.e. the index of the object in the scene); instanceCustomIndex is set to this in the code block below the text. I'll add an edit to make this clearer. Thanks!

NBickford-NV commented 1 year ago

Fixed in https://github.com/nvpro-samples/vk_raytracing_tutorial_KHR/commit/9b84682b16733a72528b72d8dce818c7f373d22e.