Negrini085 / PhotoNim

PhotoNim: a CPU raytracer with BVH optimization based on kmeans clustering
https://negrini085.github.io/PhotoNim/
GNU General Public License v3.0
4 stars 1 forks source link

Fix plane #84

Closed Negrini085 closed 4 months ago

Negrini085 commented 4 months ago

This PR should fix a bug in version 1.0.0.

When an attempt was made to construct the tree, the process was not completed because it was not possible to determine the clusters by means of kmeans. This was due to an incorrect calculation of the centroids, which had some Nan components. Firstly, an attempt was made to solve this bug by placing arbitrary centroids, only that getClosestHit, perhaps due to the infinite size of the AABBs, still did not allow the intersections with the planes to be evaluated. We therefore opted for a different approach, excluding planes from the BVHTree and adding a check on them before entering the getClosestHit proper algorithm.

Here is an example of render done with new procedure:

image

I would like to remark that you can't render a scene of only planes, because we want to have at least another shape as light emitter.