CS G140 Graduate Computer Graphics - PowerPoint PPT Presentation

About This Presentation
Title:

CS G140 Graduate Computer Graphics

Description:

2D Affine Transformations. An affine transformation is any transformation that preserves co-linearity (i.e. ... represent all 2D affine transformations as 3D ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 65
Provided by: FELL3
Category:

less

Transcript and Presenter's Notes

Title: CS G140 Graduate Computer Graphics


1
CS G140Graduate Computer Graphics
  • Prof. Harriet Fell
  • Spring 2006
  • Lecture 3 - January 30, 2006

2
Todays Topics
  • Homogeneous Coordinates
  • Viewing in 2D
  • 3D Transformations
  • Viewing from Shirley et al. Chapter 7
  • Recursive Ray Tracing
  • Reflection
  • Refraction

3
Translation
(x, y)?(xa,yb)
y
y
(a, b)
x
x
This is not a linear transformation. The origin
moves.
4
Homogeneous Coordinates
y
Embed the xy-plane in R3 at z 1. (x, y) ? (x,
y, 1)
y
x
x
z
5
2D Linear Transformations as 3D Matrices
  • Any 2D linear transformation can be represented
    by a 2x2 matrix

or a 3x3 matrix
6
2D Linear Translations as 3D Matrices
  • Any 2D translation can be represented by a 3x3
    matrix.

This is a 3D shear that acts as a translation on
the plane z 1.
7
Translation as a Shear
y
y
x
x
z
8
2D Affine Transformations
  • An affine transformation is any transformation
    that preserves co-linearity (i.e., all points
    lying on a line initially still lie on a line
    after transformation) and ratios of distances
    (e.g., the midpoint of a line segment remains the
    midpoint after transformation).
  • With homogeneous coordinates, we can represent
    all 2D affine transformations as 3D linear
    transformations.
  • We can then use matrix multiplication to
    transform objects.

9
Rotation about an Arbitrary Point
?
?
10
Rotation about an Arbitrary Point
R(?)
T(-cx, -cy)
T(cx, cy)
11
Windowing Transforms
(A,B)
(a,b)
scale
(C,D)
(C-c,D-d)
translate
(c,d)
12
3D Transformations
Remember
A 3D linear transformation can be represented by
a 3x3 matrix.
13
3D Affine Transformations
14
3D Rotations
15
Canonical View Volume
z
(1,1,1)
y
x
(-1,-1,-1)
16
Pixel Coordinates
y
y 4.5
(0,3)
(3,2)
x
(0,0)
y -03.5
x 4.5
x -0.5
17
Canonical View to Pixels
y
(1,1)
x
(-1,-1)
(-0.5, ny--0.5)
y
x
(nx-0.5, -0.5)
18
Orthographic Projection
(r,t,f)
y
(l,b,n)
z
x
left bottom near right top far
19
Orthographic Projection Math
20
Orthographic Projection Math
21
Arbitrary View Positions
v w x u
gaze
the view-up
eye
w -g g
u t x w t x w
22
Arbitrary Position Geometry
v
w
e
(ul,vb,wn)
z
u
o
(ur,vt,wf)
x
y
23
Arbitrary Position Transformation
Move e to the origin and align (u, v, w) with (x,
y, z).
Compute M MoMv. For each line segment (a,b) p
Ma, q Mb, drawline(p,q).
24
Perspective Projection
(l,b,n)
(r,t,f)
y
z
x
25
Lines to Lines
26
Perspective Geometry
View plane
y
ys
e
g
n
z
ys (n/z)y
27
Perspective Transformation
The perspective transformation should take
Where p(n) n p(f) f and n ? z1 gt z2 ?
f implies p(z1) gt p(z2).
P(z) n f fn/z satisfies these requirements.
28
Perspective Transformation
is not a linear transformation.
is a linear transformation.
29
The Whole Truth about Homogeneous Coordinates
A point in 2-space corresponds to a line through
the origin in 3-space minus the origin itself.
A point in 3-space corresponds to a line through
the origin in 4-space minus the origin itself.
30
Homogenize
31
Perspective Transformation Matrix
Compute M MoMpMv. For each line segment (a,b)
p Ma, q Mb, drawline(homogenize(p),
homogenize(q)).
32
Viewing for Ray-TracingSimplest Views
screen
(0, 0, 0)
(wd/s, ht/2, d)
(wd, ht, 0)
33
A Viewing System for Ray-Tracing
w
h
perp
gaze
eye
(ex, ey, ez)
near distance g
You need a transformation that sends (ex, ey,
ez) to (w/2, h/2, n) g to nk p to pj
34
Time for a Break
35
Recursive Ray Tracing
Adventures of the 7 Rays - Watt
Specular Highlight on Outside of Shere
36
Recursive Ray Tracing
Adventures of the 7 Rays - Watt
Specular Highlight on Inside of Sphere
37
Recursive Ray Tracing
Adventures of the 7 Rays - Watt
Reflection and Refraction of Checkerboard
38
Recursive Ray Tracing
Adventures of the 7 Rays - Watt
Refraction Hitting Background
39
Recursive Ray Tracing
Adventures of the 7 Rays - Watt
Local Diffuse Plus Reflection from Checkerboard
40
Recursive Ray Tracing
Adventures of the 7 Rays - Watt
Local Diffuse in Complete Shadow
41
Recursive Ray Tracing
Adventures of the 7 Rays - Watt
Local Diffuse in Shadow from Transparent Sphere
42
Recursive Ray-Tracing
  • How do we know which rays to follow?
  • How do we compute those rays?
  • How do we organize code so we can follow all
    those different rays?

43
select center of projection(cp) and window on
view plane for (each scan line in the image )
for (each pixel in scan line ) determine
ray from the cp through the pixel pixel
RT_trace(ray, 1) // intersect ray with
objects compute shade at closest intersection //
depth is current depth in ray tree RT_color
RT_trace (RT_ray ray int depth) determine
closest intersection of ray with an object if
(object hit) compute normal at
intersection return RT_shade (closest object
hit, ray, intersection, normal,
depth) else return
BACKGROUND_VALUE
44
// Compute shade at point on object, // tracing
rays for shadows, reflection, refraction.
RT_color RT_shade ( RT_object object, //
Object intersected RT_ray ray, // Incident
ray RT_point point, // Point of
intersection to shade RT_normal normal, //
Normal at point int depth ) // Depth in
ray tree RT_color color // Color of
ray RT_ray rRay, tRay, sRay// Reflected,
refracted, and shadow ray color ambient term
for ( each light ) sRay ray from point
to light if ( dot product of normal and
direction to light is positive ) compute how
much light is blocked by opaque
and transparent surfaces, and use to scale
diffuse and specular terms before adding them
to color
45
if ( depth lt maxDepth ) // return if depth is
too deep if ( object is reflective )
rRay ray in reflection direction from
point rColor RT_trace(rRay, depth
1) scale rColor by specular coefficient and
add to color if ( object is transparent
) tRay ray in refraction direction from
point if ( total internal reflection does not
occur ) tColor RT_trace(tRay, depth
1) scale tColor by transmission coefficient
and add to color return
color // Return the color of the ray
46
Computing R
L R (2 L?N) N R (2 L?N) N - L
I
R
N
LR
R
I
?
?
47
Reflections, no Highlight
48
Second Order Reflection
49
Refelction with Highlight
50
Nine Red Balls
51
Refraction
N
I
?I
?T
T
-N
52
Refraction and Wavelength
N
I
?I
?T
T
-N
53
Computing T
I - sin(?I)M cos(?I)N
N
T sin(?T)M - cos(?T)N
I
?I
How do we compute M, sin(?T), and cos(?T)?
We look at this in more detail
?T
T
-N
54
Computing T
?T
T
-N
55
Computing T
I
Parallel to I
?T
T
-N
cos(?T)
?I
x
sin(?T)
56
Total Internal Reflection
When is cos(?T) defined?
Then there is no transmitting ray and we have
total internal reflection.
57
Index of Refraction
  • The speed of all electromagnetic radiation in
    vacuum is the same, approximately 3108 meters
    per second, and is denoted by c. Therefore, if v
    is the phase velocity of radiation of a specific
    frequency in a specific material, the refractive
    index is given by

http//en.wikipedia.org/wiki/Refractive_index
58
Indices of Refraction
http//en.wikipedia.org/wiki/List_of_indices_of_re
fraction
59
One Glass Sphere
60
Five Glass Balls
61
A Familiar Scene
62
Bubble
63
Milky Sphere
64
Lens - Carl Andrews 1999
Write a Comment
User Comments (0)
About PowerShow.com