Intel® Embree Ray Tracing Kernels
Discussion forum on the open source ray tracing kernels for fast photo-realistic rendering on Intel® CPU(s)
280 Discussions

is there any way to limit the number of triangles per leaf to 4?

Bernie_BVH
Beginner
1,479 Views

i'm using Embree as a BVH generator, but i need to convert the results to my own BVH format which only supports 4 triangles per leaf.

currently i'm using code based off the the tutorial project "bvh_access". in this code, i get the triangles from the leaf as follows:

    embree::BVH4::NodeRef ref = ...;
    size_t num;
    const embree::Triangle4v* tris = (const embree::Triangle4v*)ref.leaf(num);

this gives me an array of Triangle4v's, each of which contains up to 4 triangles. in practice i've found that 'num' can range from 1-7 (i think). what i want is to limit the number of triangles per leaf to 4, hence 'num' would always be 1.

i've tried changing RTC_BUILD_MAX_PRIMITIVES_PER_LEAF to 4 (it is normally 32), and also setting maxLeafBlocks in bvh_node_ref.h to 1 (it is normally 7). neither of these changes appear to have any effect on the number of triangles per leaf.

0 Kudos
4 Replies
SvenW_Intel
Moderator
1,469 Views

You have to change some lines in the kernels/bvh/bvh_builder_sah.cpp. At the end of the file look for the block inside the EMBREE_GEOMETRY_TRIANGLE define. Just change all occurances of inf in this block to 4.

0 Kudos
Bernie_BVH
Beginner
1,456 Views

that didn't work. even setting it to 1 didn't work.
how can i debug this?

0 Kudos
SvenW_Intel
Moderator
1,448 Views

That really should work. Can you add some print of settings.maxLeafSize at beginning of BVHNBuilderSAH::build function in bvh_builder_sah.cpp and verify that this value is 4.

Bernie_BVH
Beginner
1,443 Views

ah! it was user error. i was copying the exe to another location and calling that with system(), but i wasn't copying embree3.dll alongside it. changes i made in bvh_access.cpp were showing up in the exe, but changes to bvh_builder_sah.cpp were showing up in the dll ..

thank you

0 Kudos
Reply