hlsl - DXR : How to identify the geometry instance of the bottom level AS inside the closest hit shader

标签 hlsl raytracing directx-12

我在单个 DXR 底层加速结构 (BLAS) 中有多个几何体 (D3D12_RAYTRACING_GEOMETRY_DESC)。我如何确定其中哪些是在最近的命中着色器中被命中的? 以下 HLSL 内部函数做一些不同的事情:

  • PrimitiveIndex() 返回当前几何体的三角形索引,但它会为 BLAS 内的每个新几何体重新启动,所以我不知道哪个被击中了。
  • InstanceIndex() 返回顶层索引,不返回底层索引
  • InstanceID() 同样,只为顶层定义

最佳答案

D3D12_RAYTRACING_TIER_1_1 开始,有一个名为 uint GeometryIndex() 的新内部函数 Specification .

关于hlsl - DXR : How to identify the geometry instance of the bottom level AS inside the closest hit shader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57943297/

相关文章:

cuda - 使用高级着色器语言进行计算算法

c++ - UWP 硬件视频解码 - DirectX12 vs Media Foundation

dxgi - 使用哪种格式来查看深度模板缓冲区资源的着色器资源?

gpu - 在计算着色器中的 N 个线程后退出

unity-game-engine - 求与无限平面相交的射线的长度

c# - 光线追踪器光线反射错误

c - 如何使用 lookAt 矩阵计算光线追踪中的光线?

graphics - 光线追踪中的光泽反射

vulkan - 什么是 DirectX 12 相当于 Vulkan 的 "transient attachment"?

c++ - HLSL代码没有注册?