RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.32k stars 383 forks source link

What am I supposed to do with Intersections with outside barycentric coordinates? #462

Open Raildex opened 9 months ago

Raildex commented 9 months ago

In my rtcSetGeometryIntersectFilterFunction for a triangle mesh I receive a negative barycentric coordinate. Since the intersection is outside of the triangle, what am I supposed to do with it?

svenwoop commented 9 months ago

In fast mode (default) it can happen that u/v coordinates are slightly out of the triangle. You can just interpolate vertex data as usual using these uv's. If this is an issue, you can also enable robust mode (RTC_SCENE_FLAG_ROBUST) which will not have this issue.

Raildex commented 9 months ago

My Scene is set to RTC_SCENE_FLAG_ROBUST and I receive illegal barycentric coords.

Within an Occluded Filter Function I use

auto u = RTCHitN_u(args->hit, args->N, i);
auto v = RTCHitN_v(args->hit, args->N, i);
if (u < 0 || u > 1 || v < 0 || v > 1) {
    throw Exception("Illegal Barycentric Coordinate!");
}
svenwoop commented 9 months ago

Please also reproduce the issue in the minimal tutorial. Is u/v smaller 0 or larger than 1?