Closed xue-fc closed 4 months ago
Just letting you know that unfortunately Jan has passed away, and as such there wont be any further updates to this project However, since I use an identitcal system to Jan here for bvh and triangle traversal, its not an issue. not sure entirely why myself(havent bothered to figure out yet), by the distances are always correct and dont need scaling in my experience thus far.
I'm very sorry to hear about the loss. His work has been very helpful to me.
If only ray.direction is scaled, the calculated tHit will be the correct value multiplied by scale. But I guess this offset will be counteracted by the transformation on triangle data, finally we get correct distance.
yeah... Again, I use basically the same system, and the hit distances are correct(compared to rasterized GBuffer), no offset is needed
Thanks for your help!
After hitting a new mesh, only origin and direction are transformed. https://github.com/jan-van-bergen/GPU-Raytracer/blob/6559ae2241c8fdea0ddaec959fe1a47ec9b3ab0d/Src/CUDA/Raytracing/BVH2.h#L105-L109
But _transforminv may contains scale transformation. https://github.com/jan-van-bergen/GPU-Raytracer/blob/6559ae2241c8fdea0ddaec959fe1a47ec9b3ab0d/Src/Renderer/Mesh.cpp#L24-L27
If scale is not identity matrix, ray.direction will not be a normalized vector after transformation. Then we get wrong _rayhit.t in this algorithm. https://github.com/jan-van-bergen/GPU-Raytracer/blob/6559ae2241c8fdea0ddaec959fe1a47ec9b3ab0d/Src/CUDA/Raytracing/Triangle.h#L148-L174
So I think we should scale tMin and tMax when transforming ray.origin and ray.direction.
Thanks for your any reply.