cs 431/636 advanced rendering techniques dr. david breen university crossings 149 tuesday 6pm ...
TRANSCRIPT
![Page 1: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/1.jpg)
CS 431/636 Advanced Rendering Techniques
Dr. David Breen
University Crossings 149
Tuesday 6PM 8:50PM
Presentation 2
4/7/09
![Page 2: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/2.jpg)
Start Up
Any questions from last time? Go over sampling image plane? Or intersection algorithms?
![Page 3: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/3.jpg)
Slide Credits
Leonard McMillan, Seth Teller, Fredo Durand, Barb Cutler - MIT
G. Drew Kessler, Larry Hodges - Georgia Institute of Technology
John Hart - University of Illinois Rick Parent - Ohio State University
![Page 4: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/4.jpg)
More Geometry & Intersections
![Page 5: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/5.jpg)
Ray/Plane Intersection
Ray is defined by R(t) = Ro + Rd*t where t 0
Ro = Origin of ray at (xo, yo, zo)
Rd = Direction of ray [xd, yd, zd] (unit vector)
Plane is defined by [A, B, C, D]
Ax + By + Cz + D = 0 for a point in the plane
Normal Vector, N = [A, B, C] (unit vector)
A2 + B2 + C2 = 1
D = - N • P0 (P0 - point in plane)
![Page 6: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/6.jpg)
Ray/Plane (cont.)
Substitute the ray equation into the plane equation:
A(xo + xdt) + B(yo + ydt) + C(zo +zdt) + D = 0
Solve for t:t = -(Axo + Byo + Czo + D) / (Axd + Byd + Czd)
t = -(N • Ro - N • P0 ) / (N • Rd)
![Page 7: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/7.jpg)
What Can Happen?
N • Rd = 0N • Rd > 0
t < 0
Ro
t > 0
Ro
![Page 8: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/8.jpg)
Ray/Plane Summary
Intersection point:(xi, yi, zi) = (xo + xdti, yo + ydti, zo + zdti)
n Calculate N • Rd and compare it to zero.
n Calculate ti and compare it to zero.
n Compute intersection point.n Flip normal if N • Rd is positive
![Page 9: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/9.jpg)
Ray-Parallelepiped Intersection Axis-aligned From (X1, Y1, Z1) to (X2, Y2, Z2) Ray P(t)=Ro+Rdt
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 10: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/10.jpg)
Naïve ray-box Intersection Use 6 plane equations Compute all 6 intersection Check that points are inside box
Ax+By+Cz+D ≤ 0
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 11: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/11.jpg)
Factoring out computation Pairs of planes have the same
normal Normals have only one non-0
component Do computations one dimension at a
time Maintain tnear and tfar (closest and
farthest so far)
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 12: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/12.jpg)
Test if parallel
If Rdx = 0, then ray is parallel If Rox < X1 or Rox > x2 return false
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
![Page 13: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/13.jpg)
If not parallel
Calculate intersection distance t1 and t2 t1 = (X1-Rox)/Rdx
t2 = (X2-Rox)/Rdx
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
t1
t2
![Page 14: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/14.jpg)
Test 1 Maintain tnear and tfar
If t1 > t2, swap if t1 > tnear, tnear = t1 if t2 < tfar, tfar = t2
If tnear > tfar, box is missed
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
t1x t2xtnear
t1y
t2ytfar
tfar
![Page 15: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/15.jpg)
Test 2
If tfar < 0, box is behind
y=Y2
y=Y1
x=X1 x=X2
Ro
Rd
t1xt2xtfar
![Page 16: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/16.jpg)
Algorithm recap Do for all 3 axes
Calculate intersection distance t1 and t2 Maintain tnear and tfar If tnear > tfar, box is missed If tfar < 0, box is behind
If box survived tests, return intersection at tnear
If tnear is negative, return tfar
y=Y2
y=Y1
x=X1 x=X2Ro
Rd
tnear
t1y
tfar
![Page 17: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/17.jpg)
Ray/Ellipsoid Intersection Ray/Cylinder Intersection
Ellipsoid's surface is defined by the set of points {(xs, ys, zs)} satisfying the equation:
(xs/ a)2 + (ys/ b)2 + (zs/ c)2 - 1 = 0
Cylinder's surface is defined by the set of points {(xs, ys, zs)} satisfying the equation:
(xs)2 + (ys)2 - r2 = 0 -z0 ≤ zs ≤ z0
Centers at origin
![Page 18: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/18.jpg)
Substitute ray equation into surface equations
This is a quadratic equation in t: At2 + Bt + C = 0
Analyze as before Solve for t with quadratic formula Plug t back into ray equation - Done Well,… not exactly
Ray/Ellipsoid Intersection Ray/Cylinder Intersection
![Page 19: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/19.jpg)
Ray/Cylinder Intersection
Is intersection point Pi between -Z0 and Z0? If not, Pi is not valid Also need to do intersection test with
z = -Z0 , Z0 plane If (Pix)2 + (Piy)2 ≤ r2, you’ve intersected a
“cap” Which valid intersection is closer?
![Page 20: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/20.jpg)
![Page 21: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/21.jpg)
Superquadrics
€
x
a1
⎛
⎝ ⎜
⎞
⎠ ⎟
2ε 2
+y
a2
⎛
⎝ ⎜
⎞
⎠ ⎟
2ε 2
⎡
⎣
⎢ ⎢
⎤
⎦
⎥ ⎥
ε 2ε1
+z
a3
⎛
⎝ ⎜
⎞
⎠ ⎟
2ε1
=1
![Page 22: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/22.jpg)
Bezier Patch Patch of order (n, m) can be defined in terms of a set
of (n + 1)(m + 1) control points Pi+1,j+1 for integer indices i = 0 to n, j = 0 to m.
€
(u,v)∈ [0,1]2
p(u,v) =i= 0
n
∑ Bin (u)B j
m (v)j= 0
m
∑ Pi+1, j +1
Bin (u) =
n
i
⎛
⎝ ⎜
⎞
⎠ ⎟u
i(1− u)n−i
![Page 23: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/23.jpg)
Tesselate Patches and Superquadrics
![Page 24: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/24.jpg)
Tesselate Patches and Superquadrics
![Page 25: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/25.jpg)
Utah Teapot
Modeled by 32 Bézier Patches Control points available at
http://www.holmes3d.net/graphics/teapot
![Page 26: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/26.jpg)
SMF Triangle Meshesv -1 -1 -1v 1 -1 -1 v -1 1 -1 v 1 1 -1 v -1 -1 1 v 1 -1 1 v -1 1 1 v 1 1 1 f 1 3 4 f 1 4 2 f 5 6 8 f 5 8 7 f 1 2 6 f 1 6 5 f 3 7 8 f 3 8 4 f 1 5 7 f 1 7 3 f 2 4 8 f 2 8 6
vertices
triangles
Draw data structure
![Page 27: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/27.jpg)
Triangle Meshes (.iv)
![Page 28: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/28.jpg)
Transformations & Hierarchical Models
![Page 29: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/29.jpg)
Add an extra dimension• in 2D, we use 3 x 3 matrices• In 3D, we use 4 x 4 matrices
Each point has an extra value, w
Homogeneous Coordinates
x'
y'
z'
w'
=
x
y
z
w
a
e
i
m
b
f
j
n
c
g
k
o
d
h
l
p
p' = M p
![Page 30: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/30.jpg)
Most of the time w = 1, and we can ignore it
Homogeneous Coordinates
x'
y'
z'
1
=
x
y
z
1
a
e
i
0
b
f
j
0
c
g
k
0
d
h
l
1
![Page 31: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/31.jpg)
Translate (tx, ty, tz)
Why bother with the extra dimension?Because now translations can be encoded in the matrix!
Translate(c,0,0)
x
y
p p'
c
x'
y'
z'
1
=
x
y
z
1
1
0
0
0
0
1
0
0
0
0
1
0
tx
ty
tz
1
x'
y'
z'
![Page 32: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/32.jpg)
Scale (sx, sy, sz) Isotropic (uniform)
scaling: sx = sy = sz
You only have to implement uniform scaling
x'
y'
z'
1
=
x
y
z
1
sx
0
0
0
0
sy
0
0
0
0
sz
0
0
0
0
1
Scale(s,s,s)
x
p
p'
qq'
y
![Page 33: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/33.jpg)
Rotation
About z axis
x'
y'
z'
1
=
x
y
z
1
cos
sin
0
0
-sin
cos
0
0
0
0
1
0
0
0
0
1
ZRotate()
x
y
z
p
p'
θ
![Page 34: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/34.jpg)
Rotation
About x axis:
About y axis:
x'
y'
z'
1
=
x
y
z
1
0
cos sin
0
0
-sin cos
0
1
0
0
0
0
0
0
1
x'
y'
z'
1
=
x
y
z
1
cos 0
-sin 0
sin 0
cos 0
0
1
0
0
0
0
0
1
![Page 35: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/35.jpg)
Rotation About (kx, ky, kz), an
arbitrary unit vector
(Rodrigues Formula)
x'
y'
z'
1
=
x
y
z
1
kxkx(1-c)+c
kykx(1-c)+kzs
kzkx(1-c)-kys
0
0
0
0
1
kykx(1-c)-kzs
kyky(1-c)+c
kzky(1-c)+kxs
0
kxkz(1-c)+kys
kykz(1-c)-kxs
kzkz(1-c)+c
0
where c = cos & s = sin
Rotate(k, )
x
y
z
θ
k
![Page 36: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/36.jpg)
How are transforms combined?
(0,0)
(1,1)(2,2)
(0,0)
(5,3)
(3,1)Scale(2,2) Translate(3,1)
TS =2
0
0
2
0
0
1
0
0
1
3
1
2
0
0
2
3
1=
Scale then Translate
Use matrix multiplication: p' = T ( S p ) = ((TS) p)
Caution: matrix multiplication is NOT commutative!
0 0 1 0 0 1 0 0 1
![Page 37: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/37.jpg)
Non-commutative CompositionScale then Translate: p' = T ( S p ) = TS p
Translate then Scale: p' = S ( T p ) = ST p
(0,0)
(1,1)(4,2)
(3,1)
(8,4)
(6,2)
(0,0)
(1,1)(2,2)
(0,0)
(5,3)
(3,1)Scale(2,2) Translate(3,1)
Translate(3,1) Scale(2,2)
![Page 38: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/38.jpg)
TS =2
0
0
0
2
0
0
0
1
1
0
0
0
1
0
3
1
1
ST =2
0
0
2
0
0
1
0
0
1
3
1
Non-commutative CompositionScale then Translate: p' = T ( S p ) = TS p
2
0
0
0
2
0
3
1
1
2
0
0
2
6
2
=
=
Translate then Scale: p' = S ( T p ) = ST p
0 0 1 0 0 1 0 0 1
![Page 39: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/39.jpg)
Transformations in Ray Tracing
![Page 40: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/40.jpg)
Transformations in Modeling
Position objects in a scene Change the shape of objects Create multiple copies of objects Projection for virtual cameras Animations
![Page 41: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/41.jpg)
Scene Description
Scene
LightsCamera ObjectsMaterialsBackground
![Page 42: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/42.jpg)
Simple Scene Description File
Camera { center 0 0 10 direction 0 0 -1 up 0 1 0 }
Lights { numLights 1 DirectionalLight { direction -0.5 -0.5 -1 color 1 1 1 } }
Background { color 0.2 0 0.6 }
Materials { numMaterials <n>
<MATERIALS> }
Group { numObjects <n> <OBJECTS> }
![Page 43: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/43.jpg)
Hierarchical Models
Logical organization of scene
![Page 44: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/44.jpg)
Group { numObjects 3 Group { numObjects 3 Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { numObjects 2 Group { Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { Box { <BOX PARAMS> } Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } Plane { <PLANE PARAMS> } }
Simple Example with Groups
![Page 45: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/45.jpg)
Group { numObjects 3 Group { numObjects 3 Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { numObjects 2 Group { Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { Box { <BOX PARAMS> } Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } Plane { <PLANE PARAMS> } }
Adding Materials
![Page 46: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/46.jpg)
Adding Transformations
![Page 47: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/47.jpg)
Using Transformations
Position the logical groupings of objects within the scene
Transformation in group
![Page 48: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/48.jpg)
Directed Acyclic Graph is more efficient and useful
![Page 49: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/49.jpg)
Processing Model Transformattions
Goal Get everything into world coordinates
Traverse graph/tree in depth-first order Concatenate transformations Can store intermediate transformations Apply/associate final transformation to
primitive at leaf node What about cylinders, superquadrics, etc.?
Transform ray!
![Page 50: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/50.jpg)
Transform the Ray
Map the ray from World Space to Object Space
World Space
r major
r minor
(x,y)
(0,0) Object Space
r = 1
pWS = M pOS
pOS = M-1 pWS
![Page 51: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/51.jpg)
Transform Ray New origin:
New direction:
originOS = M-1 originWS
directionOS = M-1 (originWS + 1 * directionWS) - M-1 originWS
originOS
originWS
directionOS
directionWS
Object SpaceWorld Space
qWS = originWS + tWS * directionWS
qOS = originOS + tOS * directionOS
directionOS = M-1 directionWS
![Page 52: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/52.jpg)
Transforming Points & Directions
Transform point
Transform direction
Map intersection point and normal back to
world coordinates
Homogeneous Coordinates: (x,y,z,w)
W = 0 is a point at infinity (direction)
![Page 53: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/53.jpg)
Transform Normals Why? They’re used for shading
object color only Diffuse Shading
![Page 54: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/54.jpg)
Transforming Normals A surface normal is a property, not a
geometric entity
Correct normal transformation matrix:
See http://www.cgafaq.info/wiki/Transforming_Normals
![Page 55: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/55.jpg)
Given overlapping shapes A and B:
Union Intersection Subtraction
Constructive Solid Geometry (CSG)
![Page 56: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/56.jpg)
How can we implement CSG?
Points on A, Outside of B
Points on B, Outside of A
Points on B, Inside of A
Points on A, Inside of B
Union Intersection Subtraction
![Page 57: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/57.jpg)
Collect all the intersections
Union Intersection Subtraction
![Page 58: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/58.jpg)
Implementing CSG
1. Test "inside" intersections:• Find intersections with A,
test if they are inside/outside B• Find intersections with B,
test if they are inside/outside A
2. Overlapping intervals:• Find the intervals of "inside"
along the ray for A and B• Compute
union/intersection/subtractionof the intervals
![Page 59: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/59.jpg)
Constructive Solid Geometry
Ray Tracing CSG Models
Rick ParentOhio State U.
![Page 60: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/60.jpg)
CSG Form object as booleans of primitive objects
Primitives: sphere, cube, cylinder, cone Boolean operators: union, intersection, difference
Tree structure used to manage operations Leaf nodes are primitive objects Intermediate nodes specify combination operator
![Page 61: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/61.jpg)
CSE 681
Union
Min (tCmin, tB
min )
B
C +
BC
Ray intersects union: at first intersection
![Page 62: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/62.jpg)
Possible ways for 2 spans to overlap
![Page 63: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/63.jpg)
Intersection
++
If ((tCmin< tB
min ) and (tCmax> tB
min ) ): tBmin
Else If ((tBmin< tC
min ) and (tBmax> tC
min ) ): tCmin
Else: none
BC
B
C
First time in B and in C
![Page 64: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/64.jpg)
Difference
-+
BC
If ((tBmin< tC
min ): tBmin
Else if (tCmax< tB
max ): tCmax
Else: none
B
C
First time in B not in C
![Page 65: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/65.jpg)
Difference
+-
BC
If ((tCmin< tB
min): tCmin
Else if (tBmax< tC
max ): tBmax
Else: none
B
C
First time in C not in B
![Page 66: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/66.jpg)
PrimitivesAnything that can be intersected (easily) with a ray
Conics: solve analytically using R(t)Convex polyhedraA plane (a cutting plane is useful)
can be used as a modeling tool (boolean operations) surface model (e.g., polyhedron) computed from CGS
or Can be used as a model representation
keep tree structure and ray trace directly
![Page 67: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/67.jpg)
Controlling the Combinations
-+
+
?
![Page 68: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/68.jpg)
Tree Structure
circlerectangle rectangle
+ +
+ -
T1T2 T3
T4
T5- +
+T1
T2
T3
![Page 69: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/69.jpg)
Tree Structure #1
![Page 70: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/70.jpg)
Tree Structure
circlerectangle rectangle
+ +
- +
T1T2 T3
T4
T5- +
+T1
T2
T3
![Page 71: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/71.jpg)
Tree Structure #2
![Page 72: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/72.jpg)
Tree Structure
• Intersect ray with leaf nodes (primitive objects)• Combine intersection spans according to intermediate nodes
• union• intersection• difference
• Might create multiple spans
![Page 73: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/73.jpg)
Union of Spans
![Page 74: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/74.jpg)
Intersection of Spans
![Page 75: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/75.jpg)
Difference of Spans
![Page 76: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/76.jpg)
Normals of CSG intersections
Normal of some surface (or its negation)
Union or intersection: positive normal of intersected surface
![Page 77: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/77.jpg)
Difference normals
• Intersection is one of:• tmin of positive object – normal of surface• tmax of negative object – negated normal
![Page 78: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/78.jpg)
Add transformations to tree
http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/model/csg.html
![Page 79: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/79.jpg)
CSE 681
Bounding Volumes
circlerectangle rectangle
+ +
+ -
T1T2 T3
T4
T5
Construction•Use bounding volumes at leaf nodes• Union bounding volumes at interior nodes
Traversal•Top-down•Test bounding volume at interior
![Page 80: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/80.jpg)
Example
![Page 81: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/81.jpg)
Example
![Page 82: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/82.jpg)
Example (Simon Chorley)
![Page 83: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/83.jpg)
Example (Simon Chorley)
![Page 84: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/84.jpg)
For example:
![Page 85: CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM 8:50PM Presentation 2 4/7/09](https://reader030.vdocuments.us/reader030/viewer/2022032803/56649e245503460f94b11f03/html5/thumbnails/85.jpg)
Wrap Up
Discuss status/problems/issues with this week’s programming assignment