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

BVH2, BVH4 change to make them find all intersections

muratmat
Beginner
517 Views

Dear Embree stuff,

First of all, my congratulations for your GREAT work!
I'm trying to modify intersect code of BVH2 and BVH4 intersectors, in order to make them find (and report) all intersections, not only the closest one.
Here's my modified code: http://pastebin.com/3226UBgd
At the moment I'm trying a simple cube geometry (4 faces, 12 triangles), so I can avoid to concentrate myself on the stack problem (reporting all intersections would need a dyamic stack, no a fixed upper bound of 1+3*BVH4::maxDepth). In addition intersection are not stored in a dynamic array, just "debugged" and printf'ed.
The steps I've done, in the intersectfunction are:

- removed the "if popped node is too far, pop next one" check
- all hit nodes are inserted in the stack
- at leaves nodes, the hit.t is set to ray.far (i.e. hit.t = ray.far)

Unfortunately it seems to not be enought (the cube geometry reports me only one intrsection).
Could you please help me? At the moment, I'm not looking at performance, just trying to make it work.

Many thanks in advance.
Regards.

0 Kudos
4 Replies
SvenW_Intel
Moderator
517 Views
It is NOT sufficient to only modify the traverser for reporting all intersections. The reason is that the ray/triangle intersector intersects batches of 4 triangles at once. Also it has to be modified to report all the intersections.
0 Kudos
Alec_J_
Beginner
517 Views

@muratmat did you manage to support finding all intersections after all? Or is this feature in Embree now? Currently I'm shooting a ray recursively from the closest hit. This is not only slow, but requires and epsilon offset that sometimes misses hits (coplanar triangles).

0 Kudos
Hamza_C_
Beginner
517 Views

I would be interested in such a feature too.

Just like Alec, I'm recursively shooting rays from the closest hit and using epsilons to avoid repetitive hits but the performance income would be great with all intersection finding support.

0 Kudos
Keymaster
New Contributor I
517 Views

you dont have to modify the traversal code at all, just modify the triangle intersector to return false every time and log the intersections of the current batch somewhere instead. One problem is that with spatialsplit data structures it is possible that single triangle will be reported multiple times, so you need to check to avoid duplicates

0 Kudos
Reply