Skip to content

Handle parallel rays on AABB faces without NaN intersections - #3793

Draft
Afloat16 wants to merge 1 commit into
nerfstudio-project:mainfrom
Afloat16:fix-parallel-ray-aabb-intersection
Draft

Afloat16 wants to merge 1 commit into
nerfstudio-project:mainfrom
Afloat16:fix-parallel-ray-aabb-intersection

Conversation

@Afloat16

@Afloat16 Afloat16 commented Oct 2, 2026

Copy link
Copy Markdown

A ray parallel to an AABB face produces 0/0 when its origin lies on that face. intersect_aabb then returns NaN crop bounds, including through Cameras.generate_rays; even interior parallel rays can have NaN backward gradients from the unused divisions.

Handle exact-zero directions using the slab constraint: a parallel ray inside the slab imposes no parameter bound; a parallel ray outside the slab misses the box. Protect the divisor before arithmetic and intersect the remaining finite intervals. Nonzero directions, including very small ones, retain the existing geometry and gradients.

Validation:

  • 13 focused tests passed on CPU Torch 2.14.1; unchanged source: 9 failed, 4 passed.
  • Tests cover float32/float64 and signed zero, box faces/edges, outside slabs, inside origins, analytic origin/direction/box gradients and gradcheck, small nonzero directions, rotated OBB crop boxes, actual camera ray generation, random nonparallel forward/gradient parity and empty batches.
  • Existing AABB tests plus regressions: 15 passed. All existing utils/cameras tests plus regressions: 44 passed (existing deprecation warnings).
  • Repository Ruff 0.12.2 configured lint/format checks for changed files, license check and git diff --check passed.

Full ns-dev-test, GPU/nerfacc execution and rendering/performance benchmarks were not run for this patch.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant