Intel® Embree Ray Tracing Kernels
Discussion forum on the open source ray tracing kernels for fast photo-realistic rendering on Intel® CPUs.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
265 Discussions

Intersection with Triangles Aligned in the Same Plane


Firstly, thanks for the great library! Really enjoying playing around with it so far.

I have a question related to how Embree handles triangles that are aligned (and overlapping) in the same plane. To illustrate this please refer to the 2D examples below. In case 1, one triangle mesh (b) is enclosed within another (a) and one side is aligned and overlapping. In case 2, the triangle meshes (a and b) are side by side but share a side.

In both of these cases I would like to receive intersection hits for each intersection. In case 1 this would be two back faces and in case 2 this would be one back face and one front face. With what I have tested so far, it seems Embree always returns a single intersection in these cases. The intersection always has the same primitive ID, so there is no z-fighting. 

Is there a way I can receive intersection hits in such cases? Thanks in advance!

0 Kudos
2 Replies

You can achieve this by using the intersection filter callback mechanism. Register a callback function that that does the following:

if (ray.hit is front facing and closer than stored front facing hit) {

   ray.frontfacing_hit = ray.hit;

} else if (ray.hit is back facing and closer than stored back facing hit) {

  ray.backfacing_hit = ray.hit;


ray.tfar = max(ray.frontfacing_hit.tfar, ray.backfacing_hit.tfar);

This intersection filter functions remembers the closest front-facing and back-facing hit in some extended ray fields (ray.frontfacing_hit and ray.backfacing_hit). At the end it resets the hit distance to the largest of the current front-facing and back-facing hit to let the traversal find any potential closer hit inbetween.

This will return the closest front and backfacing hit, which you can test for same (or similar) hit distance to detect the above cases.


Thanks Sven!