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