BVH2, BVH4 change to make them find all intersections

BVH2, BVH4 change to make them find all intersections

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.

5 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Sven Woop (Intel)

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.

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

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.

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

Melden Sie sich an, um einen Kommentar zu hinterlassen.