mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.1k stars 246 forks source link

Add support for Embree's robust intersection flag #1300

Closed dvicini closed 2 months ago

dvicini commented 2 months ago

Embree supports a fast and "robust" ray intersection mode. Mitsuba uses the default, fast mode. This is likely the best choice for general rendering tasks, but can cause issues in certain applications.

For example, some people use Mitsuba purely to do some specialized ray tracing (for its speed & simplicity). In such cases, the ray tracing might not happen in in a "Monte Carlo setting", and rays may be spawned in a structured way. In that case, it can happen that rays perfectly hit edges between triangles, which is a known failure mode of Embree's fast mode (see also https://github.com/mitsuba-renderer/mitsuba3/issues/1149).

This PR adds support to set the robust mode at runtime using a boolean flag at the scene level.

This also adds a test for the behavior. The test currently checks both failure and success of the ray tracing. I am not yet 100% sure if the failure will happen on all platforms (due to subtleties in the compilers & math eval) - to be seen once the CI runs.

I also haven't updated the documentation yet. I wasn't sure yet where would be the best place to describe scene level flags.

wjakob commented 2 months ago

This is great -- thank you, Delio!