Presentation is loading. Please wait.

Presentation is loading. Please wait.

David Luebke3/11/2016 CS 551 / 645: Introductory Computer Graphics Geometric transforms: perspective projection Color.

Similar presentations


Presentation on theme: "David Luebke3/11/2016 CS 551 / 645: Introductory Computer Graphics Geometric transforms: perspective projection Color."— Presentation transcript:

1 David Luebke3/11/2016 CS 551 / 645: Introductory Computer Graphics Geometric transforms: perspective projection Color

2 David Luebke3/11/2016 Administrivia l Problems submitting assignment 2 late l Hand out assignment 3….or not l Graphics Lunch (Glunch)…Fridays at noon, typically in Olsson 236D (this week in 228E) –uva.cs.graphics

3 David Luebke3/11/2016 Perspective Projection l We talked about geometric transforms, focusing on modeling transforms –Ex: translation, rotation, scale, gluLookAt() –These are encapsulated in the OpenGL modelview matrix l Can also express perspective projection (and other projections) as a matrix l Next few slides: representing perspective projection with the projection matrix

4 David Luebke3/11/2016 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 Luebke3/11/2016 Recap: Homogeneous Coordinates l 4x4 matrix for rotation about the X axis:

6 David Luebke3/11/2016 Recap: Homogeneous Coordinates 4x4 matrix for scaling by S x, S y, S z :

7 David Luebke3/11/2016 Recap: Homogeneous Coordinates 4x4 matrix for translating by T x, T y, T z :

8 David Luebke3/11/2016 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 :

9 David Luebke3/11/2016 Recap: Compositing Transforms l These transforms, 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

10 David Luebke3/11/2016 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 direction. (What direction?) l To help illustrate this, imagine subtracting two homogeneous points

11 David Luebke3/11/2016 Perspective Projection l In the real world, objects exhibit perspective foreshortening: distant objects appear smaller l The basic situation:

12 David Luebke3/11/2016 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?

13 David Luebke3/11/2016 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’ = ?

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

15 David Luebke3/11/2016 A Perspective Projection Matrix l Answer:

16 David Luebke3/11/2016 A Perspective Projection Matrix l Example: l Or, in 3-D coordinates:

17 David Luebke3/11/2016 A Perspective Projection Matrix OpenGL’s gluPerspective() command generates a slightly more complicated matrix: –Can you figure out what this matrix does?

18 David Luebke3/11/2016 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

19 David Luebke3/11/2016 Matrix Operations In OpenGL l Certain commands affect the current matrix in OpenGL –glMatrixMode() sets the current matrix –glLoadIdentity() replaces the current matrix with an identity matrix –glTranslate() postmultiplies the current matrix with a translation matrix –gluPerspective() postmultiplies the current matrix with a perspective projection matrix l It is important that you understand the order in which OpenGL concatenates matrices

20 David Luebke3/11/2016 Matrix Operations In OpenGL l In OpenGL: –Vertices are multiplied by the modelview matrix –The resulting vertices are multiplied by the projection matrix l Example: –Suppose you want to scale an object, translate it, apply a lookat transformation, and view it under perspective projection. What order should you make calls?

21 David Luebke3/11/2016 Matrix Operations in OpenGL l Problem: scale an object, translate it, apply a lookat transformation, and view it under perspective l A correct code fragment: glMatrixMode(GL_PERSPECTIVE); glLoadIdentity(); gluPerspective(…); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(…); glTranslate(…); glScale(…); /* Draw the object...*/

22 David Luebke3/11/2016 Matrix Operations in OpenGL l Problem: scale an object, translate it, apply a lookat transformation, and view it under perspective l An incorrect code fragment: glMatrixMode(GL_PERSPECTIVE); glLoadIdentity(); glTranslate(…); glScale(…); gluPerspective(…); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(…); /* Draw the object...*/

23 David Luebke3/11/2016 Color l Next topic: Color To understand how to make realistic images, we need a basic understanding of the physics and physiology of vision. Here we step away from the code and math for a bit to talk about basic principles.

24 David Luebke3/11/2016 Basics Of Color l Elements of color:

25 David Luebke3/11/2016 Basics of Color l Physics: –Illumination n Electromagnetic spectra –Reflection n Material properties (i.e., conductance) n Surface geometry and microgeometry (i.e., polished versus matte versus brushed) l Perception –Physiology and neurophysiology –Perceptual psychology

26 David Luebke3/11/2016 Physiology of Vision l The eye: l The retina –Rods –Cones n Color!

27 David Luebke3/11/2016 Physiology of Vision l The center of the retina is a densely packed region called the fovea. –Cones much denser here than the periphery

28 David Luebke3/11/2016 Physiology of Vision: Cones l Three types of cones: –L or R, most sensitive to red light (610 nm) –M or G, most sensitive to blue light (560 nm) –S or B, most sensitive to blue light (430 nm) –Color blindness results from missing cone type(s)

29 David Luebke3/11/2016 Physiology of Vision: The Retina l Weirdly, rods and cones are at the back of the retina, behind a mostly-transparent neural structure that collects their response.

30 David Luebke3/11/2016 Perception: Metamers l A given perceptual sensation of color derives from the stimulus of all three cone types l Identical perceptions of color can thus be caused by very different spectra

31 David Luebke3/11/2016 Perception: Other Gotchas l Color perception is also difficult because: –It varies from person to person (thus std observers) –It is affected by adaptation (transparency demo) –It is affected by surrounding color:

32 David Luebke3/11/2016 Color Spaces l Three types of cones suggests color is a 3D quantity. How to define 3D color space? l Idea: shine given wavelength ( ) on a screen, and mix three other wavelengths (R,G,B) on same screen. Have user adjust intensity of RGB until colors are identical: l How closely does this correspond to a color CRT? l Problem: sometimes need to “subtract” R to match

33 David Luebke3/11/2016 CIE Color Space l The CIE (Commission Internationale d’Eclairage) came up with three hypothetical lights X, Y, and Z with these spectra: l Idea: any wavelength can be matched perceptually by positive combinations of X,Y,Z l Note that: X ~ R Y ~ G Z ~ B

34 David Luebke3/11/2016 CIE Color Space l The gamut of all colors perceivable is thus a three-dimensional shape in X,Y,Z: l For simplicity, we often project to the 2D plane X+Y+Z=1 X = X / (X+Y+Z) Y = Y / (X+Y+Z) Z = 1 - X - Y

35 David Luebke3/11/2016 CIE Chromaticity Diagram (1931)

36 David Luebke3/11/2016 Device Color Gamuts l Since X, Y, and Z are hypothetical light sources, no real device can produce the entire gamut of perceivable color l Example: CRT monitor

37 David Luebke3/11/2016 Device Color Gamuts l The RGB color cube sits within CIE color space something like this:

38 David Luebke3/11/2016 Device Color Gamuts l We can use the CIE chromaticity diagram to compare the gamuts of various devices: l Note, for example, that a color printer cannot reproduce all shades available on a color monitor

39 David Luebke3/11/2016 Converting Color Spaces l Simple matrix operation: The transformation C 2 = M -1 2 M 1 C 1 yields RGB on monitor 2 that is equivalent to a given RGB on monitor 1

40 David Luebke3/11/2016 Converting Color Spaces l Converting between color models can also be expressed as such a matrix transform: l YIQ is the color model used for color TV in America. Y is luminance, I & Q are color –Note: Y is the same as CIE’s Y –Result: backwards compatibility with B/W TV!

41 David Luebke3/11/2016 Gamma Correction l We generally assume colors are linear l But most display devices are inherently nonlinear –I.e., brightness(voltage) != 2*brightness(voltage/2) l Common solution: gamma correction –Post-transformation on RGB values to map them to linear range on display device: –Can have separate  for R, G, B


Download ppt "David Luebke3/11/2016 CS 551 / 645: Introductory Computer Graphics Geometric transforms: perspective projection Color."

Similar presentations


Ads by Google