Rasterization couldn't handle global effects well
(Soft) shadows
Especially when the light sources bounce more than once
Glossy reflection
Indirect Illumination
Rasterization is fast, but quality is relatively low
Ray tracing is accurate, but is very slow
Rasterization: real-time
Ray tracing: offline
~10K CPU core hours to render one frame in production
Three assumptions:
Light travels in straight lines (physically wrong)
Light rays do not "collide" with each other if they cross (physically wrong)
Light rays travel from the light sources to the eye (but the physics is invariant under path reversal - reciprocity)
Pinhole Camera Model
Point Light Source
Start an eye ray at the eye and goes through pixel.
Collide with the first object, and then
(Local) Perform shading calculation to compute color of pixel
Directly project to the light source after the eye ray has collide with an object.
Then the light bounces only once.
"An improved illumination model for shaded display." - T. Whitted, CACM 1980
Simulates the recursive bouncing of light rays.
Taking both Reflection and Refraction into consideration
Different rays:
Primary Ray: Starts at the eye
Secondary Ray: Generated upon collision of primary ray
Shadow Ray: Directly connected from the intersection to the light source.
Ray Equation: A ray is defined by its origin
Intersections:
Implicit Surface: Solve for real, positive roots.
Triangle Mesh
Naïve Procedure:
Ray-plane intersection
Solving the equation gives
Remember to check whether
Test if the point is inside the triangle
Möller Trumbore Algorithm: A faster approach by examining the barycentric coordinate.
Solving the equation gives:
where
See Cramer's rule.
Inside/outside test: Fire a ray from a given point. Even number of intersections if the point is outside.
Simple ray-scene intersection
Exhaustively test ray-intersection with every triangle
Find the closest hit (i.e. minimum
Build a larger volume for testing the potential intersection quickly.
Feature:
Object is fully contained in the volume.
If the ray doesn't hit the volume, then it won't hit the object
Test BVol first, then test the object if BVol is hit.
Can be in any shape as long as it speeds up the test.
Axis-Aligned Bounding Box (AABB)
For the 3D box,
If
Equality for BBoxes that contains an axis-aligned plane only
Why Axis-Aligned?
General Plane:
3 subtractions, 6 multiplications, 1 division
Slabs perpendicular to
1 subtraction, 1 division