Presentation is loading. Please wait.

Presentation is loading. Please wait.

David Luebke11/14/2015 CS 551 / 645: Introductory Computer Graphics David Luebke

Similar presentations


Presentation on theme: "David Luebke11/14/2015 CS 551 / 645: Introductory Computer Graphics David Luebke"— Presentation transcript:

1 David Luebke11/14/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu http://www.cs.virginia.edu/~cs551

2 David Luebke11/14/2015 Administrivia l Office hours today: 4:30-5:30

3 David Luebke11/14/2015 Recap: Rigid-Body Transforms l Goal: object coordinates  world coordinates l Rigid-body transforms –Translation –Rotation –Scale –Shear

4 David Luebke11/14/2015 Recap: Transformation Matrices l Represent these transformation using matrices –Rotation, scale, shear: 3x3 matrices suffice –Would be nice to work translation and projection into the same system l Solution: homogeneous coordinates –A point in homogeneous coordinates: [x, y, z, w] T –Corresponding point in 3-D: [x/w, y/w, z/w] T –Now transformation matrices are 4x4

5 David Luebke11/14/2015 Recap: Homogeneous Coordinates l 4x4 matrix for rotation about the X axis:

6 David Luebke11/14/2015 Recap: Homogeneous Coordinates l 4x4 matrix for rotation about the Y axis:

7 David Luebke11/14/2015 Recap: Homogeneous Coordinates l 4x4 matrix for rotation about the Z axis:

8 David Luebke11/14/2015 Recap: Homogeneous Coordinates 4x4 matrix for scaling by S x, S y, S z :

9 David Luebke11/14/2015 Recap: Homogeneous Coordinates 4x4 matrix for translating by T x, T y, T z :

10 David Luebke11/14/2015 Recap: Compositing Transforms l We can composite the effect of multiple transforms by multiplying their matrices: Ex: rotate 90° about X, then 10 units down Z :

11 David Luebke11/14/2015 Recap: Compositing Transforms l Now that we can represent translation as a matrix, we can composite it with other transformations Ex: rotate 90° about X, then 10 units down Z :

12 David Luebke11/14/2015 Recap: Compositing Transforms l Now that we can represent translation as a matrix, we can composite it with other transformations Ex: rotate 90° about X, then 10 units down Z :

13 David Luebke11/14/2015 Recap: Compositing Transforms l Rigid-body transformations, in general, do not commute –Translate then rotate very different from rotate then translate l Write transforms down from right to left in the order in which they take place –Example: p’ = R y  -1 R x  -1 R z  R x  R y  p

14 David Luebke11/14/2015 More On Homogeneous Coords l The w coordinate of a homogeneous point is typically 1 l Decreasing w makes the point “bigger”, meaning further from the origin l Homogeneous points with w = 0 are thus “points at infinity”, meaning infinitely far away in some particular direction. –(What direction?) l To help illustrate this, imagine subtracting two homogeneous points

15 David Luebke11/14/2015 Perspective Projection l In the real world, objects exhibit perspective foreshortening: distant objects appear smaller l The basic situation:

16 David Luebke11/14/2015 Perspective Projection l When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world: How tall should this bunny be?

17 David Luebke11/14/2015 Perspective Projection l The geometry of the situation is that of similar triangles. View from above: l What is x’? P (x, y, z)X Z View plane d (0,0,0) x’ = ?

18 David Luebke11/14/2015 Perspective Projection Desired result for a point [x, y, z, 1] T projected onto the view plane: l What should a matrix look like to do this?

19 David Luebke11/14/2015 A Perspective Projection Matrix l Answer: l An aside: what fundamental difference do you notice about this matrix from the others?

20 David Luebke11/14/2015 A Perspective Projection Matrix l Example: l Or, in 3-D coordinates:

21 David Luebke11/14/2015 Projection Matrices l Now that we can express perspective foreshortening as a matrix, we can composite it onto our other matrices with the usual matrix multiplication l End result: a single matrix encapsulating modeling, viewing, and projection transforms l Coming up after the exam: parallel (a.k.a. orthographic) projections, and the viewport transformation

22 David Luebke11/14/2015 Review for Exam l Quick recap of lecture topics for exam… –Display technologies n Vector versus raster: what’s a pixel? n CRT (black & white, color): shadow mask, phosphors, electron guns n LCD: polarizing crystals that line up under an E-field, losing their polarization and acting as light valves n Pros and cons of different technologies –Framebuffers n Fast, dual-ported memory bank for holding pixels n True-color (24-bit) vs Pseudocolor (8-bit indexed) vs hi- color (16-bit, 6-6-4 ?)

23 David Luebke11/14/2015 Review For Exam l Color –Basic physiology: retina, rods, cones –Different types of cones: L, M, S –Metamers: perceptually identical color senstions caused by different spectra –CIE Color Space (X, Y, Z) n Color mix-and-match experiment n Hypothetical light sources X, Y, Z (why?) n Three dimensional shape, often simplified to 2-D gamut –Other color spaces (RGB, HSV) –Gamma correction: linearize non-linear response of display device

24 David Luebke11/14/2015 Review For Exam l Rasterizing lines –A methodology in optimizing code –Simplest way: solve slope-intercept equation n Check slope and step in X or Y –DDA: find incremental change per inner loop –Bresenham: take advantage of rational slope, endpoints to optimize with integer arithmetic

25 David Luebke11/14/2015 Review For Exam l Rasterizing polygons –Can break into triangles for convenience n Trivial for convex polys, difficult for complex polys –Edge equations: n Evaluate equation of edge (linear expression) per pixel n If all three edges are positive, light pixel n Can evaulate R,G,B as linear expressions too n Hardware: SIMD array n Software: bounding box n Issues: ensuring consistent edge equations, numerical stability when evaluating edge equations

26 David Luebke11/14/2015 Review For exam l Rasterizing triangles: edge walking –Find edges (DDA) –Interpolate colors down edges –Interpolate colors across scanlines –Fast: touches only pixels necessary –Difficult: lots of special cases, fractional offsets, precision worries l Rasterizing triangles: general issues –Need consistent rules about pixels right on edge

27 David Luebke11/14/2015 Review For Test l Can also rasterize general polygons –Active edge table: sort edges by y min and y max, then by x intersection w/ scanline –March up scanline by scanline, filling pixels according to parity rule –Hard to interpolate color, etc. correctly -- not planar in color space, in general

28 David Luebke11/14/2015 Review For Test l Clipping –Want only portions of lines, polygons in viewport –Cohen-Sutherland line clipping: binary outcodes –Polygon clipping is harder n Triangle in, 7-gon out n Concave polyon in, 2 polygons out –Sutherland-Hodgman: clip against view planes in succession n In-out rules n Line-plane intersection

29 David Luebke11/14/2015 Review For Test l 3-D graphics: Transform Illuminate Transform Clip Project Rasterize Model & Camera Parameters Rendering Pipeline FramebufferDisplay

30 David Luebke11/14/2015 Review For Test l Rendering pipeline: 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

31 David Luebke11/14/2015 Review For Test l Transformations –Shift in coordinate systems (basis sets) –Accomplished via matrix multiplication –Modeling transforms: object->world –Viewing transform: world->view –Projection transform: view->screen

32 David Luebke11/14/2015 Review For Test l Rigid-body transforms –Rotation: 2-D. 3-D (canonical & arbitrary axis) –Scaling –Translation: homogeneous coords, 4x4 matrices –Composiing transforms n Matrix multiplication n Order from right to left l Projection transforms –Geometry of perspective projection –Derive perspective projection matrix


Download ppt "David Luebke11/14/2015 CS 551 / 645: Introductory Computer Graphics David Luebke"

Similar presentations


Ads by Google