Presentation is loading. Please wait.

Presentation is loading. Please wait.

David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke

Similar presentations


Presentation on theme: "David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke"— Presentation transcript:

1 David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu http://www.cs.virginia.edu/~cs551

2 David Luebke1/10/2016 Side Note l Shifts versus additions

3 David Luebke1/10/2016 Where We’ve Been l Till now we’ve talked about a 2-D world l We’ve covered: –Display technology –Color –Framebuffers –Drawing 2-D lines (and drawing them fast) –Drawing 2-D polygons (especially triangles) –Clipping polygons

4 David Luebke1/10/2016 Where We’re Going l 3-D graphics (finally!) l Next lectures: –The graphics pipeline: the big picture –Rigid-body transforms n Math –Homogeneous coordinates n Math –The viewing transform n Math –The projection transform n Math

5 David Luebke1/10/2016 3-D Graphics: A Whirlwind Tour Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay

6 David Luebke1/10/2016 The Display You Know Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay

7 David Luebke1/10/2016 The Framebuffer You Know Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay

8 David Luebke1/10/2016 The Rendering Pipeline Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay l Why do we call it a pipeline?

9 David Luebke1/10/2016 2-D Rendering You Know Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay

10 David Luebke1/10/2016 Edge Equations You Know V2V2 V1V1 V0V0 l Find edge equations

11 David Luebke1/10/2016 Edge Equations You Know V2V2 V1V1 V0V0 - + l Disable processors where plugging (X proc, Y proc ) into edge equation of {V 0,V 1 } evaluates to negative

12 David Luebke1/10/2016 Edge Equations You Know V2V2 V1V1 V0V0 l Find edge equations

13 David Luebke1/10/2016 Edge Equations You Know V2V2 V1V1 V0V0 + - l Disable processors where plugging (X proc, Y proc ) into edge equation of {V 2,V 0 } evaluates to negative

14 David Luebke1/10/2016 Edge Equations You Know V2V2 V1V1 V0V0 + - l Disable processors where plugging (X proc, Y proc ) into edge equation of {V 2,V 1 } evaluates to negative

15 David Luebke1/10/2016 Edge Equations You Know V2V2 V1V1 V0V0 l All enabled processors evaluate linear expressions for triangle color, depth, etc.

16 David Luebke1/10/2016 Edge Walking (You Know?) l Traditional method: –Find edge equations {V 0 V 1 } {V 0 V 2 } {V 2 V 1 } –Find and fill spans where scanlines cross the edge –Just a bilinear interpolation! V0V0 V2V2 V1V1

17 David Luebke1/10/2016 The Rendering Pipeline: 3-D Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay

18 David Luebke1/10/2016 The Rendering Pipeline: 3-D Modeling Transforms Scene graph Object geometry Lighting Calculations Viewing Transform Clipping Projection Transform Result: All vertices of scene in shared 3-D “world” coordinate system All vertices of scene in shared 3-D “world” coordinate system Vertices shaded according to lighting model Vertices shaded according to lighting model Scene vertices in 3-D “view” or “camera” coordinate system Scene vertices in 3-D “view” or “camera” coordinate system Exactly those vertices & portions of polygons in view frustum Exactly those vertices & portions of polygons in view frustum 2-D screen coordinates of clipped vertices 2-D screen coordinates of clipped vertices

19 David Luebke1/10/2016 The Rendering Pipeline: 3-D Scene graph Object geometry Lighting Calculations Clipping Result: All vertices of scene in shared 3-D “world” coordinate system All vertices of scene in shared 3-D “world” coordinate system Vertices shaded according to lighting model Vertices shaded according to lighting model Scene vertices in 3-D “view” or “camera” coordinate system Scene vertices in 3-D “view” or “camera” coordinate system Exactly those vertices & portions of polygons in view frustum Exactly those vertices & portions of polygons in view frustum 2-D screen coordinates of clipped vertices 2-D screen coordinates of clipped vertices Modeling Transforms Viewing Transform Projection Transform

20 David Luebke1/10/2016 Rendering: Transformations l So far, discussion has been in screen space l But model is stored in model space (a.k.a. object space or world space) l Three sets of geometric transformations: –Modeling transforms –Viewing transforms –Projection transforms

21 David Luebke1/10/2016 Rendering: Transformations l Modeling transforms –Size, place, scale, and rotate objects parts of the model w.r.t. each other –Object coordinates  world coordinates Z X Y X Z Y

22 David Luebke1/10/2016 Rendering: Transformations l Viewing transform –Rotate & translate the world to lie directly in front of the camera n Typically place camera at origin n Typically looking down -Z axis –World coordinates  view coordinates

23 David Luebke1/10/2016 Rendering: Transformations l Projection transform –Apply perspective foreshortening n Distant = small: the pinhole camera model –View coordinates  screen coordinates

24 David Luebke1/10/2016 Rendering: Transformations l All these transformations involve shifting coordinate systems (i.e., basis sets) l That’s what matrices do… l Represent coordinates as vectors, transforms as matrices l Multiply matrices = concatenate transforms!                     Y X Y X   cossin cos

25 David Luebke1/10/2016 Rendering: Transformations l Homogeneous coordinates: represent coordinates in 3 dimensions with a 4-vector –Denoted [x, y, z, w] n Note that typically w = 1 in model coordinates –To get 3-D coordinates, divide by w: [x’, y’, z’] = [x/w, y/w, z/w] l Transformations are 4x4 matrices l Why? To handle translation and projection

26 David Luebke1/10/2016 Rendering: Transformations l OpenGL caveats: –All modeling transforms and the viewing transform are concatenated into the modelview matrix –A stack of modelview matrices is kept –The projection transform is stored separately in the projection matrix l See Chapter 3 of the OpenGL book

27 David Luebke1/10/2016 The Rendering Pipeline: 3-D Modeling Transforms Scene graph Object geometry Lighting Calculations Viewing Transform Clipping Projection Transform Result: All vertices of scene in shared 3-D “world” coordinate system All vertices of scene in shared 3-D “world” coordinate system Vertices shaded according to lighting model Vertices shaded according to lighting model Scene vertices in 3-D “view” or “camera” coordinate system Scene vertices in 3-D “view” or “camera” coordinate system Exactly those vertices & portions of polygons in view frustum Exactly those vertices & portions of polygons in view frustum 2-D screen coordinates of clipped vertices 2-D screen coordinates of clipped vertices

28 David Luebke1/10/2016 Rendering: Lighting l Illuminating a scene: coloring pixels according to some approximation of lighting –Global illumination: solves for lighting of the whole scene at once –Local illumination: local approximation, typically lighting each polygon separately l Interactive graphics (e.g., hardware) does only local illumination at run time

29 David Luebke1/10/2016 The Rendering Pipeline: 3-D Modeling Transforms Scene graph Object geometry Lighting Calculations Viewing Transform Clipping Projection Transform Result: All vertices of scene in shared 3-D “world” coordinate system All vertices of scene in shared 3-D “world” coordinate system Vertices shaded according to lighting model Vertices shaded according to lighting model Scene vertices in 3-D “view” or “camera” coordinate system Scene vertices in 3-D “view” or “camera” coordinate system Exactly those vertices & portions of polygons in view frustum Exactly those vertices & portions of polygons in view frustum 2-D screen coordinates of clipped vertices 2-D screen coordinates of clipped vertices

30 David Luebke1/10/2016 Rendering: Clipping l Clipping a 3-D primitive returns its intersection with the view frustum: l See Foley & van Dam section 19.1

31 David Luebke1/10/2016 Rendering: Clipping l Clipping is tricky! In: 3 vertices Out: 6 vertices Clip In: 1 polygon Out: 2 polygons

32 David Luebke1/10/2016 The Rendering Pipeline: 3-D Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay

33 David Luebke1/10/2016 Modeling: The Basics l Common interactive 3-D primitives: points, lines, polygons (i.e., triangles) l Organized into objects –Collection of primitives, other objects –Associated matrix for transformations l Instancing: using same geometry for multiple objects –4 wheels on a car, 2 arms on a robot

34 David Luebke1/10/2016 Modeling: The Scene Graph l The scene graph captures transformations and object-object relationships in a DAG l Objects in black; blue arrows indicate instancing and each have a matrix Robot BodyHead ArmTrunkLegEyeMouth

35 David Luebke1/10/2016 Modeling: The Scene Graph l Traverse the scene graph in depth-first order, concatenating transformations l Maintain a matrix stack of transformations ArmTrunk Leg EyeMouth HeadBody Robot Foot Matrix Stack Visited Unvisited Active

36 David Luebke1/10/2016 Modeling: The Camera l Finally: need a model of the virtual camera –Can be very sophisticated n Field of view, depth of field, distortion, chromatic aberration… –Interactive graphics (OpenGL): n Pinhole camera model u Field of view u Aspect ratio u Near & far clipping planes n Camera pose: position & orientation

37 David Luebke1/10/2016 Modeling: The Camera l These parameters are encapsulated in a projection matrix –Homogeneous coordinates  4x4 matrix! –See OpenGL Appendix F for the matrix l The projection matrix premultiplies the viewing matrix, which premultiplies the modeling matrices –Actually, OpenGL lumps viewing and modeling transforms into modelview matrix

38 David Luebke1/10/2016 Rigid-Body Transforms l Goal: object coordinates  world coordinates l Idea: use only transformations that preserve the shape of the object –Rigid-body or Euclidean transforms –Includes rotation, translation, and scale l To reiterate: we will represent points as column vectors:

39 David Luebke1/10/2016 Vectors and Matrices l Vector algebra operations can be expressed in this matrix form –Dot product: –Cross product: n Note: use right-hand rule!

40 David Luebke1/10/2016 Translations l For convenience we usually describe objects in relation to their own coordinate system –Solar system example l We can translate or move points to a new position by adding offsets to their coordinates: –Note that this translates all points uniformly

41 David Luebke1/10/2016 3-D Rotations l Rotations in 2-D are easy: l 3-D is more complicated –Need to specify an axis of rotation –Common pedagogy: express rotation about this axis as the composition of canonical rotations n Canonical rotations: rotation about X-axis, Y-axis, Z-axis

42 David Luebke1/10/2016 3-D Rotations l Basic idea: –Using rotations about X, Y, Z axes, rotate model until desired axis of rotation coincides with Z-axis –Perform rotation in the X-Y plane (i.e., about Z-axis) –Reverse the initial rotations to get back into the initial frame of reference l Objections: –Difficult & error prone –Ambiguous: several combinations about the canonical axis give the same result –For a different approach, see McMillan’s lecture 12


Download ppt "David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke"

Similar presentations


Ads by Google