Classic Ray Tracing
Document Sample


Ray Tracing
Today
Basic algorithms
Overview of pbrt
Ray-surface intersection for single surface
Next lecture
Acceleration techniques for ray tracing large
numbers of geometric primitives
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Classic Ray Tracing
Greeks: Do light rays proceed from the eye to the light,
or from the light to the eye?
Gauss: Rays through lenses
Three ideas about light
1. Light rays travel in straight lines
2. Light rays do not interfere with each other if they
cross
3. Light rays travel from the light sources to the
eye (but the physics is invariant under path reversal
- reciprocity).
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray Tracing in Computer Graphics
Appel 1968 - Ray casting
1. Generate an image by sending one ray per pixel
2. Check for shadows by sending a ray to the light
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray Tracing in Computer Graphics
Whitted 1979
Recursive ray tracing (reflection and refraction)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (g/m 10)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (mirror 0)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (mirror 1)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (mirror 2)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (mirror 5)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (mirror 10)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (glass 0)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (glass 1)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (glass 2)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (glass 5)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (glass 10)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Spheres-over-plane.pbrt (glass 10)
CS348B Lecture 2 Pat Hanrahan, Spring 2005
History
Polygons Appel ‘68
Quadrics, CSG Goldstein & Nagel ‘71
Tori Roth ‘82
Bicubic patches Whitted ‘80, Kajiya ‘82
Superquadrics Edwards & Barr ‘83
Algebraic surfaces Hanrahan ‘82
Swept surfaces Kajiya ‘83, van Wijk ‘84
Fractals Kajiya ‘83
Height fields Coquillart & Gangnet ’84, Musgrave ‘88
Deformations Barr ’86
Subdivision surfs. Kobbelt, Daubert, Siedel, ’98
P. Hanrahan, A survey of ray-surface intersection algorithms
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Surface Intersection
Ray-Plane Intersection
Ray: P O t D t
D
0t N
O P
Plane: (P P) N 0
P
ax by cz d 0
Solve for intersection
Substitute ray equation into plane equation
(P P ) N (O t D P ) N 0
(O P ) N
t
DN
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Polyhedra
Ray-Slab Note: Procedural geometry
t1 t2
Ray-Box Ray-Convex Polyhedra
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Triangle Intersection 1
P1 Barycentric coordinates
P s1P1 s2P2 s3P3
s2 s3
Inside triangle criteria
P
P3 s1 0 s1 1
P2 0 s2 1
0 s3 1
s1 area( PP2 P3 )
s1 s2 s3 1
s2 area( PP3P1 )
s3 area( PP1P2 )
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Triangle Intersection 2
P s1P1 s2 P2 s3P3
s1
P
1 P2 P3 s2 P
s3
s1 P2 P3
s P P P
2 3 1
s3 P1 P2
CS348B Lecture 2 Pat Hanrahan, Spring 2005
2D Homogeneous Coordinates
x1 y1 z1
P1 P2 P3 x2 y2 z2
x3 y3 z3
x1 y1 z1
area(P1P2 P3 ) x2 y2 z2
x3 y3 z3
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Triangle Intersection 3
P P2 P3 P2 P3
s1 P P P2 P3
P1 P2 P3
P1 P P3 P3 P1
s2 P P P3 P1
P1 P2 P3
P1 P2 P P P
s3 P 1 2 P P1 P2
P1 P2 P3
s1 P2 P3
s P P P
2 3 1
s3 P1 P2
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Polygon Intersection
1. Find intersection with plane of support
2. Test whether point is inside 3D polygon
a. Project onto xy plane
b. Test whether point is inside 2D polygon
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Point in Polygon
inside(vert v[], int n, float x, float y)
{
int cross=0; float x0, y0, x1, y1;
x0 = v[n-1].x - x;
y0 = v[n-1].y - y;
while( n-- ) {
x1 = v->x - x;
y1 = v->y - y;
if( y0 > 0 ) {
if( y1 <= 0 )
if( x1*y0 > y1*x0 ) cross++;
}
else {
if( y1 > 0 )
if( x0*y1 > y0*x1 ) cross++;
}
x0 = x1; y0 = y1; v++;
}
return cross & 1;
}
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Sphere Intersection
D Ray: P O tD
P
O
2
Sphere: P C R2 0
C
2
O t D C R2 0
b b2 4ac at 2 bt c 0
t
2a
a D2
b 2 (O C) D
c (O C) 2 R 2
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Geometric Methods
Methods N
Find normal and tangents
P, u, v
Find surface parameters
T
S
e.g. Sphere
Normal N PC
Parameters x sin cos tan 1( x, y)
y sin sin cos1 z
z cos
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Implicit Surface Intersection
f ( x, y, z) 0 1. Substitute ray equation
2. Find positive, real roots
x x0 x1 t
Univariate root finding
y y0 y1 t Newton’s method
z z0 z1 t
Regula-falsi
Interval methods
Heuristics
f (t ) 0
*
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Ray-Algebraic Surface Intersection
Degree n
pn ( x, y, z) 0 Linear: Plane
Quadric: Spheres, …
x x0 x1 t Quartic: Tori
y y0 y1 t
z z0 z1 t Polynomial root finding
Quadratic, cubic, quartic
Bezier/Bernoulli basis
p (t ) 0
*
n
Descartes’ rule of signs
Sturm sequences
CS348B Lecture 2 Pat Hanrahan, Spring 2005
Related docs
Other docs by ewghwehws
Control system for dynamoelectric machines with differentially excited fields
Views: 0 | Downloads: 0
Get documents about "