Nima Kalantari
CSCE 441 - Computer Graphics
Ray Tracing (Intro)
Some slides from Ren Ng, Ravi Ramamoorthi, and Scott Schaefer
Rasterization
Effects needed for Realism
From Wikipedia
Ray Tracing
Light Rays
Outline
Ray Casting
Ray Casting - Generating Eye Rays
eye point
image plane
light source
eye ray �(starts at eye and goes through pixel)
closest scene�intersection point
note: more intersection points
Ray Casting - Shading Pixels (Local Only)
eye point
image plane
light source
eye ray �(starts at eye and goes through pixel)
perform shading calculation here to compute color of pixel (e.g. Phong model)
N
P
L
Local Shading
Ray Casting - Shading Pixels (no shadows)
eye point
image plane
light source
eye ray �(starts at eye and goes through pixel)
perform shading calculation here to compute color of pixel (e.g. Phong model)
N
P
L
Shadows
Ray Casting – Shadows
eye point
image plane
light source
eye ray �(starts at eye and goes through pixel)
perform shading calculation here to compute color of pixel (e.g. Phong model)
N
P
L
Illumination without shadow
Illumination with shadow
Outline
Recursive Ray Tracing
Spheres and Checkerboard, T. Whitted, 1979
Recursive Ray Tracing - Reflection
eye point
image plane
light source
Recursive Ray Tracing - Reflection
eye point
image plane
N
R
light source
Mirror ray�(specular reflection)
Reflection
Surface
Recursive Ray Tracing - Reflection
eye point
image plane
light source
Recursive Ray Tracing - Reflection
eye point
image plane
light source
Shadow rays
Refraction
refracted vector
Image taken from http://hyperphysics.phy-astr.gsu.edu/hbase/geoopt/refr2.html
Snell’s Law
Surface
c=speed of light in vacuum
Recursive Ray Tracing – Reflection & Refraction
eye point
image plane
light source
Recursive Ray Tracing – Reflection & Refraction
eye point
image plane
light source
Truncate at finite depth!
Recursive Ray Tracing
Truncate at finite depth!
+
+
+
Recursive Ray Tracing
For each pixel
Recursive Ray Tracing – Reflection
0
1
eye point
image plane
light source
2
Outline
Ray Equation
unit direction
origin
“time”
point along ray
Ray equation:
Example:
Ray is defined by its origin and a direction vector
Ray Intersection With Sphere
Ray:
Sphere:
Solve for intersection:
Plane Equation
Plane is defined by normal vector and a point on plane
Example:
Plane Equation:
normal vector
any point
all points on plane
Ray Intersection With Plane
Ray equation:
Plane equation:
Solve for intersection
Check:
Ray Intersection With Triangle
Ray Intersection With Triangle Mesh
Möller Trumbore Algorithm
Why care about performance?
Ray Tracing vs Rasterization
for each pixel
for each primitive
color the pixel
for each primitive
for each pixel
color the pixel
Offline*
Movies, Animations
Real-Time
Games