Ray fails to intersect at corner of triangle

Ray fails to intersect at corner of triangle

I have a half/sphere geometry , radius 1, of about 325 triangles. The triangular geometry is properly connected with no overlapping/'duplicated' nodes. I am firing rays from the origin towards the surface of the sphere. As a test of robustness I set up the rays to be directed towards the 3D "nodes" that make up the geometry. I am finding some ( say 1-2%) of the rays are recording "no hit". Obviously there is a question of geometric robustness when a ray is hitting right at a 3D node shared by maybe 4 triangles. But I thought embree would be particularly robust when dealing with this type of problem. What am I missing here? I am using 2.16.5


7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You are likely using the default fast mode, which does some optimizations that reduce precision. Please set the RTC_SCENE_ROBUST mode and try again.

Adding the flag RTC_SCENE_ROBUST helped. It reduced the number of "misses" from 20 to 2. Sadly 0 is the only acceptable result. The attached image shows one point which one ray 'missed'.

Should I try upgrading to to 2.17.2?


Downloadimage/jpeg Capture.JPG70.44 KB

attached is the half sphere as an STL

Ray that "misses" has origin 0,0,0. Direction -0.000000028097142    0.642787635000000    0.766044438000000

But I full expect that numerical precision changes when going from text will mean that the issue is not easy to reproduce.



Downloadapplication/zip Half Sphere.zip7.7 KB

Upgrading to 2.17.2 did not make any difference to this issue. There are many use cases that require the intersection routines to be geometrically robust. I understand how a point on a boundary could be missed, but this ray is intersecting the geometry at a  location where a number of triangles meet. It is indeterminate which triangle should be selected, but it should pick one.

The robust ray/triangle intersector used by Embree uses a consistent edge test (consistent for neighboring triangles) and conservative ray/box intersection during traversal. This algorithm makes the mesh ALMOST watertight, in particular along the edge where most algorithms have problems. However, exactly at the vertex there can still be issues.

A fix could be to add a small epsilon at kernels/geometry/triangle_intersector_pluecker.h, by replacing minUVW >= 0 | maxUVW <= 0 by minUVW >= -eps | maxUVW <= +eps.



OK, I do notice that it does work well along the edge. Now I know where to look, I can go into at the code and make the suggested change to see if this fixes my issue. I would suggest this change should be rolled into the master branch for 'robust mode'.

Leave a Comment

Please sign in to add a comment. Not a member? Join today