Ta: Ryan Freedman Sushma Kini Chi Zhou
Pipeline Clipping Transformation, homogeneous coordinates Lighting Perspective Viewing
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
Serial Parametric Polygon Concave 3-D
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) y = top y = bottom x = leftx = right
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
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
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
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
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)
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)
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
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)
Give transformation matrix for: Rotation by about y axis Squash 0.5 times along x-axis Translate one unit along z-axis
Give transformation matrix for: Rotation by about y axis Squash 0.5 times along x-axis Translate one unit along z-axis or
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
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
Model Coords World Coords Viewing Coords Clip Coords Screen Coords x y z x y lookat point eye point
1. Translate the eye point to the origin 2. Rotate the view vector into the negative z-axis x y z x y z
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
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 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)
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
x y z x y z Model Coords World Coords Viewing Coords Clip Coords Screen Coords
screen -z y z view y view d y clip
Create a perspective projection matrix P for a perspective view where the projection plane is a distance of 10 units from the eye.