#Need Help With Faulty BVH Builder

11 messages · Page 1 of 1 (latest)

tidal token
#

I've been following https://jacco.ompf2.com/2022/04/13/how-to-build-a-bvh-part-1-basics/ for my BHV implementation and I've encountered a bug that I just cannot for the life of me debug.

Previously, when I was using median longest axis split, my BVH construction would terminate early due to nodes being split such that one of the child nodes is completely empty which caused a lot of triangle dense leaves, not ideal. I thought this might just be a result of always going with median longest axis split and not considering other axes, so I moved on to SAH builder thinking everything would be fixed.

This only ended up being partially true... Now, leaves have at most 2 triangles, as I expected, but something else is going wrong and I think it's linked to the problem I may have had with the old builder. To me it looks like only one of the branches from the root node seems to be splitting properly and I really have no clue how to begin debugging this. I'll attach an image of a heatmap of the node intersections which gives me this impression.

I'd really appreciate any help, thanks!

cedar stag
#

That tutorial includes all the code.The best way to debug is to compare your code and the tutorial code and see where they are different.

tidal token
#

I will compare again

cedar stag
#

Is that the 0 plane for one coordinate where the errors are on one side?

#

Could be a copy/paste error where an x is a y or something like that. Perhaps when evaluating box cost or deciding splitting plane?

tidal token
#

Sorry for the slow replies by the way. I've been quite busy past few days

cedar stag
#

It can be anything. It's impossible to say from the image. It's just a thought. Comparing less than etc. The only way is to find where your implementation differs from the tutorial code. Perhaps you can run both with the same input and either use debugger or print statements to see where they diverge.

tidal token
tidal token
#

@cedar stag The problem was with how I grew the aabbs. I stopped using glm::min for comparisons and it started working... Very annoying