Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BVH Cost Function #51

Open
mmostajab opened this issue Dec 23, 2015 · 2 comments
Open

BVH Cost Function #51

mmostajab opened this issue Dec 23, 2015 · 2 comments

Comments

@mmostajab
Copy link

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:

            // Either create leaf or split primitives at selected SAH bucket
            if (nPrimitives > maxPrimsInNode || minCost < nPrimitives) split the node
            else                                                                                       create leaf node

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).

splitting_or_not_splitting

@mmp
Copy link
Owner

mmp commented Mar 5, 2016

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.

@mmostajab
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants