Ray Intersections and Hit Intervals
Solve a ray–sphere intersection and maintain an allowed parameter interval when several roots or objects lie along one ray.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Substitute the ray into the surface equation
For ray \(o+td\) and sphere with center \(c\) and radius \(r\), solve \(\|o+td-c\|^2=r^2\). Expanding yields a quadratic in \(t\). A ray from \((0,0,0)\) along the positive \(z\)-axis meets a sphere centered at \(z=5\) of radius one at parameters four and six. The smaller permitted root is the entry hit. A root behind the ray origin is outside a forward-ray interval.
Bounds keep comparisons consistent
A renderer can shorten the current parameter upper bound after finding a candidate, so later tests need only look for a closer valid hit. Near tangency or very large coordinates, numeric error can perturb the discriminant or root values. Stable formulas explain why algebraic forms matter there. Differentiable rendering studies changes to visibility where the selected hit can switch.[1]