Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ta: Ryan Freedman Sushma Kini Chi Zhou.  Pipeline  Clipping  Transformation, homogeneous coordinates  Lighting  Perspective  Viewing.

Similar presentations


Presentation on theme: "Ta: Ryan Freedman Sushma Kini Chi Zhou.  Pipeline  Clipping  Transformation, homogeneous coordinates  Lighting  Perspective  Viewing."— Presentation transcript:

1 Ta: Ryan Freedman Sushma Kini Chi Zhou

2  Pipeline  Clipping  Transformation, homogeneous coordinates  Lighting  Perspective  Viewing

3 Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords. Clipping Window Coordinates Window Coordinates Window to Viewport Window to Viewport Coordinates Viewport Coordinates Clip Coords. Viewing Coords Perspective Distortion

4  Serial  Parametric  Polygon  Concave  3-D

5  First clip 0001  Move (x 0,y 0 ) to (left,…)  Then clip 0010  Move (x 1,y 1 ) to (right,…)  Then clip 0100  Move (x 0,y 0 ) again, now to (…,bottom)  Finally clip 1000  Move (x 1,y 1 ) again, now to (…,top) 1000 0100 00010010 0101 10011010 0110 y = top y = bottom x = leftx = right

6  Compute ordered list of t-intersections 0 < t left < t bottom < t top < t right < 1  And corresponding orientations enter, enter, leave, leave (x0,y0)(x0,y0) (x1,y1)(x1,y1) t left = (left – x 0 ) / (x 1 – x 0 ) t right = -(right – x 0 ) / -(x 1 – x 0 ) t bottom = (bottom – y 0 ) / (y 1 – y 0 ) t top = -(top – y 0 ) / -(y 1 – y 0 ) y = top y = bottom x = leftx = right enter leave enter leave

7  Compute ordered list of t-intersections 0 < t left < t bottom < t top < t right < 1  And corresponding orientations enter, enter, leave, leave  Keep only the pair (x0,y0)(x0,y0) (x1,y1)(x1,y1) t left = (left – x 0 ) / (x 1 – x 0 ) t right = -(right – x 0 ) / -(x 1 – x 0 ) t bottom = (bottom – y 0 ) / (y 1 – y 0 ) t top = -(top – y 0 ) / -(y 1 – y 0 ) y = top y = bottom x = leftx = right enter leave

8  Sutherland-Hodgman  Polygon ABC  Clip left: A 1 BCA 2  Clip right: A 1 B 1 B 2 CA 2  Clip bottom: A 1 B 1 ’B 2 ’CA 2  Clip top: A 1 B 1 ’B 2 ’C 1 C 2 A 2 y = top y = bottom x = leftx = right A 1’ B 1’ C A2A2 B2B2 A1A1 B1B1 C1C1 C2C2

9  Sutherland-Hodgman  Clip segments even if they are trivially rejectible  Outputs a single polygon that appears as multiple polygons  Reversed edges don’t get filled

10  Need to keep depth (z-coordinate) of geometry for visible surface detection  Generalize oriented screen edge to oriented clipping plane C = (A,B,C,D)  Then any homogeneous point P = (x,y,z,w) T classified as  “on” if C P = 0  “in” if C P > 0  “out” if C P < 0 left right bottom top near far Ax + By + Cz + D = 0  wAx + wBy + wCz + wD = 0 (A,B,C)(A,B,C)

11 Recall that a 2-D parametric line segment from (x 0,y 0 ) to (x 1,y 1 ) is described by the equations x(t) = x 0 + t(x 1 – x 0 ) and y(t) = y 0 + t(y 1 – y 0 ), and recall the clipping window extends from (-1,-1) to (1,1). What are the (x,y) coordinates of the two points where the line segment from (-4,-1) to (3,2) intersects the clipping boundary? (Hint: we know that it goes through the left boundary)

12 Recall that a 2-D parametric line segment from (x 0,y 0 ) to (x 1,y 1 ) is described by the equations x(t) = x 0 + t(x 1 – x 0 ) and y(t) = y 0 + t(y 1 – y 0 ), and recall the clipping window extends from (-1,-1) to (1,1). What are the (x,y) coordinates of the two points where the line segment from (-4,-1) to (3,2) intersects the clipping boundary? x(t) = -4 + t(3 - -4) = 7t – 4 y(t) = -1 + t(2 - -1) = 3t – 1 When x = -1: t = 3/7, y = 9/7 – 1 = 2/7 When x = 1: t = 5/7, y = 15/7 – 1 = 8/7 When y = -1: t = 0, x = -4 When y = 1: t = 2/3, x = 14/3 – 4 = 1/3

13 Recall that a 2-D parametric line segment from (x 0,y 0 ) to (x 1,y 1 ) is described by the equations x(t) = x 0 + t(x 1 – x 0 ) and y(t) = y 0 + t(y 1 – y 0 ), and recall the clipping window extends from (-1,-1) to (1,1). What are the (x,y) coordinates of the two points where the line segment from (-4,-1) to (3,2) intersects the clipping boundary? x(t) = -4 + t(3 - -4) = 7t – 4 y(t) = -1 + t(2 - -1) = 3t – 1 When x = -1: t = 3/7, y = 9/7 – 1 = 2/7 When x = 1: t = 5/7, y = 15/7 – 1 = 8/7 When y = -1: t = 0, x = -4 When y = 1: t = 2/3, x = 14/3 – 4 = 1/3 Answer: (1/3,1) & (-1,2/7)

14

15

16

17

18 Give transformation matrix for: Rotation by 180 0 about y axis Squash 0.5 times along x-axis Translate one unit along z-axis

19 Give transformation matrix for: Rotation by 180 0 about y axis Squash 0.5 times along x-axis Translate one unit along z-axis or

20 v – view vector: v = (e – x)/||e – x|| l – light vector: l = (lp – x)/||lp – x|| n – normal vector: n = (x 1 -x 0 )  (x 2 -x 0 )/||(x 1 -x 0 )  (x 2 -x 0 )|| v l e lp x n x0x0 x2x2 x1x1 LiLi LoLo

21 Monochromatic lighting, L o = k a L a + L i (k d n  l + k s (v  r) n )  L a : Ambient component of light source  k a : Ambience reflection constant  L i : Incident light  k s : Specular reflection constant  k d : Diffuse reflection constant

22 Model Coords World Coords Viewing Coords Clip Coords Screen Coords x y z x y lookat point eye point

23 1. Translate the eye point to the origin 2. Rotate the view vector into the negative z-axis x y z x y z

24  Orthogonalize lookat vector system  Let r = v  up/||v  up||  Let u = r  v  Create rotation matrix from to R r = x, R u = y, R v = -z x y z up u v r

25 IN A WORLD… the eye is at position (5,0,0) looking at the origin, where up is the +y direction, find a viewing transformation that transforms this world into viewing coordinates such that the eye is at the origin looking down the negative z axis, and the +y direction is vertical.

26 Step 1: Find the lookat vector, the unit vector from the eye toward the point being looked at. L = (0,0,0) - (5,0,0) = (-5,0,0) Step 2: Translate eye to origin with a transformation matrix T. Normalize get (-1,0,0)

27 IN A WORLD… the eye is at position (5,0,0) looking at the origin, where up is the +y direction, find a viewing transformation that transforms this world into viewing coordinates such that the eye is at the origin looking down the negative z axis, and the +y direction is vertical. Step 3: Rotate lookat vector into –z axis. Translation moves lookat point (0,0,0) to (-5,0,0), so the lookat vector is in the direction of –x. Hence we need just a CCW -90 degree rotation about y axis. Step 4: Combine the transformation. V = RT

28 x y z x y z Model Coords World Coords Viewing Coords Clip Coords Screen Coords

29 screen -z y z view y view d y clip

30 Create a perspective projection matrix P for a perspective view where the projection plane is a distance of 10 units from the eye.


Download ppt "Ta: Ryan Freedman Sushma Kini Chi Zhou.  Pipeline  Clipping  Transformation, homogeneous coordinates  Lighting  Perspective  Viewing."

Similar presentations


Ads by Google