Download presentation
Presentation is loading. Please wait.
1
CS 551 / 645: Introductory Computer Graphics
Review for Midterm David Luebke /30/2018
2
Administrivia Hand out assignment 2 Hand in assignment 3
Late day policy: 1 late day = due tomorrow at noon Subsequent late days add 24 hours each Weekends and holidays count Compiling with C++ UNIX C++ compilers: g++ and /bin/CC I’ll make sure it works before next assignment David Luebke /30/2018
3
Midterm Examination Midterm is this Thursday (March 9) Study aids:
This lecture Earlier lectures (available on course page) Last semester’s midterm See But, its not quite the same material No calculators! (you won’t need them) David Luebke /30/2018
4
Display Technologies Cathode Ray Tubes
Earliest, still most common graphical display Understand the basic mechanism Vacuum tube, phosphors, electron beam Pros: bright, fairly high-res, leverages TV tech Cons: bulky, size-limited, finicky David Luebke /30/2018
5
Display Technologies Vector versus raster display
Vector: traces lines like an oscilloscope Pros: bright, crisp, uniform lines Cons: wireframe only, flicker for complex scenes Raster: fixed scan pattern for electron beam, intensity controlled by scan-out from frame buffer Pros: display solid objects, image complexity limited only by framebuffer resolution Cons: discreet sampling (aliasing), memory cost David Luebke /30/2018
6
Display Technologies LCDs Understand the basic mechanism
Polarized light, crystals twist 90º unless excited Basically a light valve: reflective or transmissive Pros: light-weight and thin Cons: expensive, high-power (when backlit), limited in size David Luebke /30/2018
7
Display Technologies Also know: Plasma display panels
Digital Micromirror Devices David Luebke /30/2018
8
Framebuffers Memory array storing image in pixels
Issues: memory speed, size, bus contention Different types in common use, motivated mainly by memory cost True-Color: 24 bits, 8 per RGB (or 32 bits with ) Hi-Color: 16 bits (R = 6, G = 6, B = 4) Pseudo-Color: 8 bits index into 256-entiry color lookup table (entries typically 24-bits) David Luebke /30/2018
9
Mathematical Foundations
Geometry (2-D, 3-D) Trigonometry Vector spaces Elements: scalars and vectors Operations: Addition (identity & inverse) Scalar multiplication (distributive rule) Linear combinations, dimension, basis sets Inner (dot) product, vector (cross) product David Luebke /30/2018
10
Mathematical Foundations
Affine spaces Elements: points Operations: Subtraction (point - point = vector) Addition (vector + point = point) Matrices Linear transforms, vector-matrix multiplication Matrix-matrix multiplication Composition of linear transforms = matrix concatenation David Luebke /30/2018
11
The Rendering Pipeline
Transform Illuminate Clip Project Rasterize Model & Camera Parameters Rendering Pipeline Framebuffer Display David Luebke /30/2018
12
The Rendering Pipeline: 3-D
Scene graph Object geometry Result: All vertices of scene in shared 3-D “world” coordinate system Vertices shaded according to lighting model Scene vertices in 3-D “view” or “camera” coordinate system Exactly those vertices & portions of polygons in view frustum 2-D screen coordinates of clipped vertices Modeling Transforms Lighting Calculations Viewing Transform Clipping Projection Transform David Luebke /30/2018
13
Geometric Transforms Modeling transforms: object coordinates world coordinates Viewing transform: world coordinates eye coordinates eye coordinates == camera coordinates == view coordinates Projection transform: eye coordinates 2-D screen coordinates David Luebke /30/2018
14
Geometric Transforms Understand homogeneous coordinates
[x, y, z, w]T == (x/w, y/w, z/w) Allows us to capture translation and projection as matrices Know your 4x4 Euclidean transform matrices: Translation, scale, rotation about X, Y, Z Understand rotation about an arbitrary axis Understand order of composition for matrices In OpenGL: using column vectors as points order from right to left David Luebke /30/2018
15
Perspective Projection
Geometry of the perspective projection: P (x, y, z) X Z View plane d (0,0,0) x’ = ? David Luebke /30/2018
16
Perspective Projection
Desired result: David Luebke /30/2018
17
Perspective Projection
A matrix that accomplishes this: David Luebke /30/2018
18
Rasterizing Lines Review McMillan’s great java-enabled lecture
First stab: slope-intercept + symmetry A case study in optimization Special case boundary conditions if necessary Optimize inner loops Incremental update using DDA (biggest win) Low-level tricks: integer arithmetic, compare to 0, etc. Culmination: Bresenham’s algorithm Be aware of diminishing returns and readability/portability tradeoffs David Luebke /30/2018
19
Rasterizing Triangles
Triangles are nice to deal with because they are always planar and always convex Triangle rasterization techniques: REYES: recursive subdivision of primitive Warnock: recursive subdivision of screen Edge walking Edge equations David Luebke /30/2018
20
Rasterizing Triangles
Edge walking: Draw edges vertically Fill in horizontal spans for each scanline Interpolate colors down edges At each scanline, interpolate edge colors across span Pros: Fast: touch only lit pixels, touch pixels only once Cons: Finicky: lots of special cases, hard to get just right David Luebke /30/2018
21
Rasterizing Triangles
Edge Equations Equation of a line defines two half-spaces Triangle can be represented as intersection of three half-spaces: A1x + B1y + C1 < 0 A2x + B2y + C2 < 0 A3x + B3y + C3 < 0 A1x + B1y + C1 > 0 A3x + B3y + C3 > 0 A2x + B2y + C2 > 0 David Luebke /30/2018
22
Rasterizing Triangles
Basic algorithm: Walk pixels in bounding box Evaluate three edge equations If all are greater than zero, shade pixel Issues: Computing edge equations: numerical precision Interpolating parameters (i.e., color): just like another edge equation (why?) Optimizing the algorithm Like line rasterization: DDA, early termination, etc. David Luebke /30/2018
23
Rasterizing General Polygons
B C D E F G I H Parity test: Starting outside polygon, count edges crossed. Odd = inside, even = outside Big cost: testing every edge against every pixel Solution: the active edge table algorithm Sort edges by Y Keep a list of edges that intersect current scanline, sorted by their X-intersection w/ scanline David Luebke /30/2018
24
Clipping Lines Cohen-Sutherland Algorithm
Clip 2-D line segments to rectangular viewport Designed for rapid trivial accept & trivial reject ops 4-bit outcodes divide screen into 9 regions Bitwise operations determine whether to accept, reject, or intersect with a viewport edge & recurse May require multiple iterations David Luebke /30/2018
25
Clipping Polygons Clipping polygons fundamentally more difficult
Polygons can gain or lose edges Concave polygons can even multiply Sutherland-Hodgman Algorithm Simplify by divide-and-conquer: consider each clipping plane individually Input: polygon as ordered list of vertices Output: polygon as ordered list of vertices Lends itself to pipelined hardware implementation David Luebke /30/2018
26
Clipping Polygons Sutherland-Hodgman Algorithm Know the details:
Point-plane test Line-plane intersection Rules: inside outside inside outside inside outside inside outside p p s s p s p s p output i output no output i output p output David Luebke /30/2018
27
Clipping in 3-D Problem: clipping under perspective must happen before homogeneous divide Solution 1: clip to hither plane in eye coordinates, then multiply by projection matrix, then do homogeneous divide Better: transform to canonical perspective coordinates to simplify clipping Solution 2: clip after projection (must clip all 4 homogeneous coordinates) Solution 3 (ugly but common): clip to hither & yon before projection, clip to 2-D viewport after projection and divide David Luebke /30/2018
28
Color Rods and cones Cones and color perception Gamma correction
Metamers 3-D color: X, Y, and Z; CIE color space Gamma correction David Luebke /30/2018
29
Lighting Definitions: illumination, lighting, shading Illumination:
Direct versus indirect Light properties: geometry, spectrum Common simplifications: ambient, directional, and point Surface material: geometry, reflectance, microstructure Common simplification: Phong lighting Diffuse (Lambertian) reflection: incoming light reflected equally in all directions, proportional to N • L Specular reflection: approximate falloff with (V • R)nshiny David Luebke /30/2018
30
Lighting Putting it all together: the Phong lighting model
Note: evaluate per light, per color component Common simplification: constant V (viewer infinitely far away) David Luebke /30/2018
31
Shading Where to apply lighting calculations?
Once per face: flat shading Once per vertex, interpolate resulting color: Gouraud shading Once per pixel, interpolating normal vectors from vertices: Phong shading Flat shading Phong Shading David Luebke /30/2018
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.