Download presentation
Presentation is loading. Please wait.
Published byNicholas Merritt Modified over 9 years ago
1
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20161 CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006 Lecture 3 - January 30, 2006
2
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20162 Today’s Topics Homogeneous Coordinates Viewing in 2D 3D Transformations Viewing – from Shirley et al. Chapter 7 Recursive Ray Tracing Reflection Refraction
3
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20163 Translation y x y x (a, b) This is not a linear transformation. The origin moves. (x, y) (x+a,y+b)
4
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20164 Homogeneous Coordinates x x y z y Embed the xy-plane in R 3 at z = 1. (x, y) (x, y, 1)
5
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20165 2D Linear Transformations as 3D Matrices Any 2D linear transformation can be represented by a 2x2 matrix or a 3x3 matrix
6
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20166 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
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20167 Translation as a Shear x x y z y
8
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20168 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
College of Computer and Information Science, Northeastern UniversityFebruary 3, 20169 y x Rotation about an Arbitrary Point y x
10
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201610 y x Rotation about an Arbitrary Point T(-c x, -c y ) R( ) T(c x, c y )
11
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201611 Windowing Transforms (a,b) (A,B) (c,d) (C,D) (C-c,D-d) (A-a,B-b) translate scale translate
12
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201612 3D Transformations Remember: A 3D linear transformation can be represented by a 3x3 matrix.
13
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201613 3D Affine Transformations
14
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201614 3D Rotations
15
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201615 Canonical View Volume (-1,-1,-1) (1,1,1) x y z
16
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201616 (3,2) (0,0) (0,3) Pixel Coordinates y x x = -0.5 y = 4.5 y = -03.5 x = 4.5
17
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201617 y x (-1,1) (1,-1) reflect Canonical View to Pixels y x (-1,-1) (1,1) x (-n x /2,n y /2) y (n x /2,-n y /2) scale y x (-0.5, n y --0.5) (n x -0.5, -0.5) translate
18
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201618 Orthographic Projection ( l,b,n ) ( r,t,f ) x y z left bottom near right top far
19
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201619 Orthographic Projection Math
20
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201620 Orthographic Projection Math
21
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201621 Arbitrary View Positions g aze t he view-up e ye w = -g ||g|| u = t x w ||t x w|| v = w x u
22
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201622 Arbitrary Position Geometry e v u w (u=r,v=t,w=f) (u=l,v=b,w=n) o z y x
23
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201623 Arbitrary Position Transformation Move e to the origin and align (u, v, w) with (x, y, z). Compute M = M o M v. For each line segment (a,b) p = Ma, q = Mb, drawline(p,q).
24
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201624 Perspective Projection ( l,b,n ) ( r,t,f ) x y z
25
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201625 Lines to Lines
26
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201626 Perspective Geometry g View plane y ysys n z y s = (n/z)y e
27
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201627 Perspective Transformation The perspective transformation should take Where p(n) = n p(f) = f and n z 1 > z 2 f implies p(z 1 ) > p(z 2 ). P(z) = n + f – fn/z satisfies these requirements.
28
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201628 Perspective Transformation is not a linear transformation. is a linear transformation.
29
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201629 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
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201630 Homogenize
31
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201631 Perspective Transformation Matrix Compute M = M o M p M v. For each line segment (a,b) p = Ma, q = Mb, drawline(homogenize(p), homogenize ( q)).
32
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201632 Viewing for Ray-Tracing Simplest Views (0, 0, 0) (wd, ht, 0) screen (wd/s, ht/2, d)
33
A Viewing System for Ray-Tracing g aze e ye near distance = |g| (e x, e y, e z ) = w h perp (w/2, h/2, n) (0, 0, 0) (w, h, 0) |p|j -nk-nk You need a transformation that sends (e x, e y, e z ) to (w/2, h/2, n) g to –nk p to |p|j
34
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201634 Time for a Break
35
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201635 Recursive Ray Tracing Adventures of the 7 Rays - Watt Specular Highlight on Outside of Shere
36
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201636 Adventures of the 7 Rays - Watt Specular Highlight on Inside of Sphere Recursive Ray Tracing
37
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201637 Adventures of the 7 Rays - Watt Reflection and Refraction of Checkerboard Recursive Ray Tracing
38
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201638 Adventures of the 7 Rays - Watt Refraction Hitting Background Recursive Ray Tracing
39
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201639 Adventures of the 7 Rays - Watt Local Diffuse Plus Reflection from Checkerboard Recursive Ray Tracing
40
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201640 Adventures of the 7 Rays - Watt Local Diffuse in Complete Shadow Recursive Ray Tracing
41
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201641 Adventures of the 7 Rays - Watt Local Diffuse in Shadow from Transparent Sphere Recursive Ray Tracing
42
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201642 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 < 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
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201646 Computing R I N R I R L+R L + R = (2 L N) N R = (2 L N) N - L ININ ININ
47
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201647 Reflections, no Highlight
48
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201648 Second Order Reflection
49
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201649 Refelction with Highlight
50
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201650 Nine Red Balls
51
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201651 Refraction N -N I T TT II
52
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201652 Refraction and Wavelength N -N I T TT II
53
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201653 Computing T N -N I M T TT II sin( I ) cos( I ) I = - sin( I )M + cos( I )N T = sin( T )M - cos( T )N How do we compute M, sin( T ), and cos( T )? We look at this in more detail
54
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201654 Computing T -N T TT II x sin( T ) cos( T )
55
Computing T -N T TT II = x sin( T ) cos( T ) II I Parallel to I
56
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201656 Total Internal Reflection When is cos( T ) defined? Then there is no transmitting ray and we have total internal reflection.
57
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201657 Index of Refraction The speed of all electromagnetic radiation in vacuum is the same, approximately 3×108 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 byphase velocity http://en.wikipedia.org/wiki/Refractive_index
58
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201658 Indices of Refraction Material at λ=589.3 nm vacuum1 (exactly) helium1.000036 air at STP1.0002926 water ice1.31 liquid water (20°C)1.333 ethanol1.36 glycerine1.4729 rock salt1.516 glass (typical)1.5 to 1.9 cubic zirconia2.15 to 2.18 diamond2.419 http://en.wikipedia.org/wiki/List_of_indices_of_refraction
59
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201659 One Glass Sphere
60
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201660 Five Glass Balls
61
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201661 A Familiar Scene
62
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201662 Bubble
63
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201663 Milky Sphere
64
College of Computer and Information Science, Northeastern UniversityFebruary 3, 201664 Lens - Carl Andrews 1999
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.