Path Tracing with Babylon, Background and Implementation

That’s a cool app! Thanks for the loading code sharing offer, but my difficulties lie not so much in the loading, but how to take all of that loaded data and turn every triangle and every material (and possible texture) associated with each triangle into a representation that is ray tracing friendly. Leaving out materials and just focusing on geometry for instance, all of the triangles of all of the different possible components (each piece of furniture, each wall of the room, etc) need to be fused together into a single monolithic model. This is for acceleration structure building purposes when ray casting against all of those triangles. If this is not done, then an approach like NVIDIA’S is required, where each component (piece of furniture for example) gets its own personal acceleration structure for its own set of triangles. But then, an over-arching top level acceleration structure over all of these mini acceleration structures must be constructed.

When adding in materials, if the 1st option is chosen, we have to be very careful in retaining some sort of lookup id for each and every triangle, and then load all of the textures onto the GPU where they be can looked up on a per-triangle texture unit ID basis. I have the beginnings of this in the glTF model viewer demo over at my Three.js-PathTracing-Renderer repo, but it is too fragile and non-robust for general use.

If the 2nd option is chosen, the texturing id problem might be a little easier (unless a piece of furniture has more than one material texture!), but the problem arises of building and updating a double acceleration structure (TLAS and BLAS, Top-level acc structure and Bottom-level acceleration structure). I can currently do 1 bottom level fairly well for any kind of single model with single overarching texture applied to the model as a whole. But i have yet to attempt gathering all of these up into a top level structure that has pointers to their materials and such. It’s challenging no matter what path you choose, ha.

As mentioned, I’ve made some progress in both areas, but im still learning how to integrate all of the seperate pieces of knowledge into a solution that handles arbitrary scenes and glTF models.

-Erich