Open mmostajab opened 8 years ago
I'm not sure what change you're suggesting. Is it to always create a leaf if nPrimitives <= maxPrimsInNode? I tried that change and for the two scenes I tried, saw a 10%-30% slowdown.
Yeah. Right.
I am using the acceleration structure for raytracing volumetric data and by this change I got performance improvement. I don't remember how much was it. But logically, it makes sense to always split when the number of primitives get smaller than maximum primitives in the node. In the example above, what performance improvement do we get by splitting? I think it makes sense to not split.
In bounding volume hierarchy building function, I believe there is a condition in one if-statement which prevents us to use the maximum number of primitives in node properly. The code is as follows:
The minCost < nPrimitives is usually fulfilled and a leaf node with maximum primitives in that leaf node is created in very rare cases but as we all knows, when the number of primitives per node is less than maxPrimsInNode, it is better to not split in most cases. Have a look on the attached image. The SAH cost function returns 2.625 for all possible split and it is less than 4 (number of triangles), so the triangles are split. But, it is not give us any performance improvement (it even can adds some overheads).