Intel® Embree Ray Tracing Kernels
Discussion forum on the open source ray tracing kernels for fast photo-realistic rendering on Intel® CPU(s)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
288 Discussions

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

Bernie_BVH
Beginner
2,267 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
2,257 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
2,244 Views

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

0 Kudos
SvenW_Intel
Moderator
2,236 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
2,231 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