mitsuba-renderer / drjit

Dr.Jit — A Just-In-Time-Compiler for Differentiable Rendering
BSD 3-Clause "New" or "Revised" License
597 stars 45 forks source link

Fix DDA for rays aligned with grid edges and zero-direction rays #311

Closed lnuic closed 4 days ago

lnuic commented 5 days ago

Overview

This PR addresses three bugs identified in the DDA ray traversal algorithm and introduces corresponding tests. The issues fixed are as follows:

  1. Rays along grid edges (red) Rays that pass exactly along the edges of the grid were not handled correctly.
  2. Axis-aligned rays missing the grid (blue) Rays aligned with the coordinate axes wrongly intersected the grid.
  3. Rays with negative zero direction (green) Rays with a negative zero direction component of -0.0, e.g., $ray_{d4}=[-1.0,-0.0]$, were not properly traversed.

Changes

Visualization

The following diagram illustrates the fixed scenarios: dda_fix_ray_along_edges

wjakob commented 4 days ago

This is great, thank you so much Lovro. I was trying to handle some corner cases in the code, but it seems there are so many more.. nice job tracking them all down!

wjakob commented 4 days ago

(Let's maybe wait 1-2 more days to merge this until the Mitsuba release is wrapped up.)