Raytracing 1: Intersections
different type of rays need different information, shadow rays intersection / no intersection. primary rays: point of intersection materials, normal, text coord .. etc
Ray-Sphere Intersection
Substitute:
Simplify
Substitute:
quadratic equation for t
- 2 real positive roots: pick smaller root
- both roots same: tangent to sphere
- one positive, one negative root: ray origin inside sphere ( pic + root)
- complex roots: not intersection (check discriminant of equation first)
Intersection point
substitute t back to the ray equation. surface normal at point of intersection:
Ray-Triangle Intersection
- one approach: Ray-Plane intersection, then check if inside triangle
Combine with ray equation
- still need to find intersection point inside the polygon
- Ray intersection inside triangle odd amount in, even out
- we find parametrically [barycentric coordinates]
Other primitives: cones, cylinders, ellipsoids
Boxes (useful for bounding boxes)
Many more primitives
Ray-Tracing Transformed objects
We have ray-sphere test but want to test ellipsoid
- apply inverse transform to ray, use ray-sphere
- allows instancing
- general 4×4 transform M (matrix stacks)
- apply inverse transform of M to ray
- do standard ray-surface intersection as modified
- transform intersection back to actual coordinates