webgpu icon indicating copy to clipboard operation
webgpu copied to clipboard

Getting normals for RT

Open yourconst opened this issue 2 years ago • 0 comments

Hello, I need to get the normal to the surface that the ray hits. Basically, at least the coordinates of the vertices of the triangle are required.

I found this article https://www.khronos.org/blog/introducing-vulkan-ray-tracing-position-fetch-extension It follows from it that you can get the coordinates of the vertices as follows:

#extension GL_EXT_ray_tracing_position_fetch : require
...
vec3 vertPos0 = gl_HitTriangleVertexPositionsEXT[0];
vec3 vertPos1 = gl_HitTriangleVertexPositionsEXT[1];
vec3 vertPos2 = gl_HitTriangleVertexPositionsEXT[2];

But in addition to this, it is necessary to enable the VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DATA_ACCESS_KHR flag in the acceleration structure during build. Tell me how to do this in your library?

In addition, tell me, is it possible to add an array of normals/UVs to geometry (from an .obj file for example) without using additional uniform buffers for ray tracing shaders? Well, one more question: how to add textures/materials for objects in order to render many different objects in one call?

yourconst avatar Oct 13 '23 07:10 yourconst