Ray-Slab Intersection

R(t) = Ro + Rd*t
t = ( Dn - Pn* Ro) / ( Pn * Rd)
so
t near = ( Dnear - Pn* Ro) / ( Pn * Rd)
t far = ( Dfar - Pn* Ro) / ( Pn * Rd)


  • If ( Pn * Rd) is less than zero then the roles of the near and far values must be reversed.

  • If ( Pn * Rd) is close to zero, replace it by a large number.