Docsity

Advanced Rendering Techniques: CS 431/636 Lecture Notes by Dr. David Breen - Prof. David E, Exams of Computer Science

Toggle sidebar
bg1
1!
CS 431/636 !
Advanced Rendering Techniques"
Dr. David Breen"
University Crossings 149"
Tuesday 6PM → 8:50PM"
Presentation 2"
4/7/09"
Start Up"
 Any questions from last time?"
 Go over sampling image plane?"
 Or intersection algorithms?"
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"
More Geometry & Intersections
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)"
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)"
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Advanced Rendering Techniques: CS 431/636 Lecture Notes by Dr. David Breen - Prof. David E and more Exams Computer Science in PDF only on Docsity!

CS 431/

Advanced Rendering Techniques

Dr. David Breen

University Crossings 149

Tuesday 6PM → 8:50PM

Presentation 2

Start Up

 Any questions from last time?

 Go over sampling image plane?

 Or intersection algorithms?

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

More Geometry & Intersections

Ray/Plane Intersection

Ray is defined by R(t) = R

o

+ R

d

*t where t ≥ 0

R

o

= Origin of ray at (x

o

, y

o

, z

o

R

d

= Direction of ray [x

d

, y

d

, z

d

] (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)

A

+ B

+ C

D = - N • P

(P

- point in plane)

Ray/Plane (cont.)

Substitute the ray equation into the plane

equation:

A(x

o

+ x

d

t) + B(y

o

+ y

d

t) + C(z

o

+z

d

t) + D = 0

Solve for t:

t = -(Ax

o

+ By

o

+ Cz

o

+ D) / (Ax

d

+ By

d

+ Cz

d

t = -(N • R

o

  • N • P 0

) / (N • R

d

What Can Happen?

N • Rd = 0 N • Rd > 0

t < 0

Ro

t > 0

Ro

Ray/Plane Summary

Intersection point:

(x

i

, y

i

, z

i

) = (x

o

+ x

d

t

i

, y

o

+ y

d

t

i

, z

o

+ z

d

t

i

1. Calculate N • R

d

and compare it to zero.

2. Calculate t

i

and compare it to zero.

3. Compute intersection point.

4. Flip normal if N • R

d

is positive

Ray-Parallelepiped Intersection

 Axis-aligned

 From (X1, Y1, Z1) to (X2, Y2, Z2)

 Ray P(t)=R

o

+R

d

t

y=Y

y=Y

x=X1 x=X

R

o

R

d

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=Y

y=Y

x=X1 x=X

R

o

Rd

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=Y

y=Y

x=X1 x=X

Ro

R

d

Test if parallel

 If R

d

x = 0, then ray is parallel

 If R

o

x < X1 or R

o

x > x2 return false

y=Y

y=Y

x=X1 x=X

R

o

R

d

Ray/Cylinder Intersection

 Is intersection point P

i

between -Z

and Z

 If not, P

i

is not valid

 Also need to do intersection test with

z = -Z

, Z

plane

 If (P

i

x)

+ (P

i

y)

≤ r

, youʼve intersected a

“cap”

 Which valid intersection is closer?

Superquadrics

x

a 1

2 ε (^2)

y

a 2

2

ε 2 ε 1

z

a 3

2 ε 1

Bezier Patch

 Patch of order (n, m) can be defined in terms of a set

of (n + 1)(m + 1) control points P

i+1,j+

for integer

indices i = 0 to n, j = 0 to m.

( u , v ) ∈ [0, 1 ]

p ( u , v ) =

i = 0

n

∑ Bi

n

( u ) B

j

m

( v )

j = 0

m

∑ Pi + 1 , j + 1

B

i

n

( u ) =

n

i

 u

i

( 1 − u )

n − i

Tesselate Patches and

Superquadrics

Tesselate Patches and

Superquadrics

Utah Teapot

 Modeled by 32 Bézier Patches

 Control points available at http://

www.holmes3d.net/graphics/teapot

SMF Triangle Meshes

v -1 -1 - v 1 -1 - v -1 1 - v 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

Triangle Meshes (.iv)

Transformations &

Hierarchical Models

 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

 Most of the time w = 1, and we can

ignore it

Homogeneous Coordinates

x'

y'

z'

x

y

z

a

e

i

b

f

j

c

g

k

d

h

l

Non-commutative Composition

Scale then Translate: p' = T ( S p ) = TS p

Translate then Scale: p' = S ( T p ) = ST p

Scale(2,2) Translate(3,1)

Translate(3,1) Scale(2,2)

TS =

ST =

Non-commutative Composition

Scale then Translate: p' = T ( S p ) = TS p

Translate then Scale: p' = S ( T p ) = ST p

Transformations in Ray Tracing

Transformations in Modeling

 Position objects in a scene

 Change the shape of objects

 Create multiple copies of objects

 Projection for virtual cameras

 Animations

Scene Description

Scene

Camera Lights Background Materials Objects

Simple Scene Description File

Camera { center 0 0 10 direction 0 0 - up 0 1 0 }

Lights { numLights 1 DirectionalLight { direction -0.5 -0.5 - color 1 1 1 } }

Background { color 0.2 0 0.6 }

Materials { numMaterials }

Group { numObjects }

Hierarchical Models

 Logical organization of scene

Group { numObjects 3 Group { numObjects 3 Box { } Box { } Box { } } Group { numObjects 2 Group { Box { }

Box { } Box { } } Group {

Box { } Sphere { } Sphere { } } }

Plane { } }

Simple Example with Groups

Group { numObjects 3 Group { numObjects 3 Box { } Box { } Box { } } Group { numObjects 2

Group { Box { } Box { } Box { } }

Group { Box { } Sphere { }

Sphere { } } } Plane { } }

Adding Materials

Adding Transformations

Using Transformations

 Position the logical

groupings of objects

within the scene

 Transformation in group

Directed Acyclic Graph

is more efficient and useful

-- Leaf Node (superquadric)

-- Non-Leaf Node

(boolean operation)

-- Transformation

Given overlapping shapes A and B:

Union Intersection Subtraction

Constructive Solid Geometry

(CSG)

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

Collect all the intersections

Union Intersection Subtraction

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/

subtraction

of the intervals

Constructive Solid

Geometry

Ray Tracing CSG

Models

Rick Parent

Ohio State U.

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

CSE 681

Union

Min (t C min, t

B

min )

B

C +

C B

Ray intersects union: at first intersection

Possible ways for 2

spans to overlap

Intersection

If ((t

C

min

< t

B

min

) and (t

C

max

> t

B

min

) ): t

B

min

Else If ((t

B

min

< t

C

min

) and (t

B

max

> t

C

min

) ): t

C

min

Else: none

C B

B

C

First time in B and in C

Difference

C B

If ((t

B

min< t

C

min ): t

B

min

Else if (t

C

max

< t

B

max

): t

C

max

Else: none

B

C

First time in B not in C

Difference

C^ B

If ((t

C

min< t

B

min): t

C

min

Else if (t

B

max

< t

C

max

): t

B

max

Else: none

B

C

First time in C not in B

Primitives

Anything that can be intersected (easily) with a ray

Conics: solve analytically using R(t)

Convex polyhedra

A 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

Union of Spans Intersection of Spans

Difference of Spans

Normals of CSG intersections

Normal of some surface (or its negation)

Union or intersection:

positive normal of intersected surface

Difference normals

  • Intersection is one of:
    • t min

of positive object – normal of surface

  • t max

of negative object – negated normal

Add transformations to tree

http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/model/csg.html

CSE 681

Bounding Volumes

circle

rectangle rectangle

T2 T

T

T

T

Construction

  • Use bounding

volumes at leaf nodes

  • Union bounding

volumes at interior

nodes

Traversal

  • Top-down
  • Test bounding

volume at interior

Example

Example Example (Simon Chorley)

Example (Simon Chorley)

For example: