Graphics Review Geometry, Color & Shading

23
Graphics Review Geometry, Color & Shading Brad Tennis Leslie Wu 10.24.06

description

Graphics Review Geometry, Color & Shading. Brad Tennis Leslie Wu 10.24.06. Topics. Foundations of 2D graphics Coordinate systems Matrices Transformations Algorithms Splines. Topics cont. Color Physical Basis, Representation Reflection Models Shading. Coordinate Systems. - PowerPoint PPT Presentation

Transcript of Graphics Review Geometry, Color & Shading

Graphics Review

Geometry,Color & Shading

Brad Tennis

Leslie Wu

10.24.06

Topics

● Foundations of 2D graphics Coordinate systems Matrices Transformations Algorithms Splines

Topics cont.

● Color Physical Basis, Representation Reflection Models Shading

Coordinate Systems

Cartesian coordinates

(x, y)

note: (xh, y

h, h) with h = 0

corresponds to point at infinity

Homogeneous coordinate

(xh, y

h, h)

where

x = xh / h

y = yh / h

Basic definitions

● Affine transformation: Parallel lines map to parallel lines Finite points map to finite points Examples in 2D:

● Translation, rotation, scaling, reflection, shear

Transformation Matrices

● Translation

● Rotation

● Scaling

x 'y '1 =1 0 t x0 1 t y0 0 1⋅xy1

x 'y '1 =cos −sin 0sin cos 0

0 0 1⋅xy1

x 'y '1 =sx 0 00 s y 00 0 1⋅xy1

Matrix Properties

● Translation is additive

● Rotation is additive

● ...both are commutative

● Rotation matrices are orthogonal

T x1 , y1⋅T x2 , y2=T x1x2 , y1 y2

R 2⋅R 1=R 21

A⋅B=B⋅A

Algorithms

● Clipping Interior = saves inside region Exterior = saves parts outside of region

● Intersection Point in triangle

● Can be computed using cross-products (see handout)

Splines

● Spline curve Composite curve made out of polynomial sections Satisfies continuity conditions at section boundaries

Control points

Control graph / characteristic polygon

Continuity

● Parametric continuity Zero-order (C0) : curves meet First-order (C1) : first parametric derivatives same Second-order (C2): 1st and 2nd derivatives same

● Geometric continuity

Zero-order (G0) : same as C0

First-order (G1) : 1st derivatives proportional Second-order (G2) : 1st and 2nd derivatives proportional

Bezier Splines● Properties

Curve is polynomial of degree (# control points – 1) Can be defined recursively

● For example, to plot midpoint of Bezier of degree two

Physical Basis

•Humans can distinguish roughly 10 million colors

•The eye has three different types of cones

•The response of each peaks at either 420, 534 or 564 nm

http://en.wikipedia.org/wiki/Image:Srgbspectrum.png

Additive Color

•Combination of emitters of different wavelengths

•RGB Color (e.g., monitors)

http://en.wikipedia.org/wiki/Image:RGB_illumination.jpg

Subtractive Color

•Combination of absorbers of different wavelengths

•CMYK Color (e.g., printers)

http://en.wikipedia.org/wiki/Image:Synthese-.svg

Color Representation

•Each light is modeled as the summation of three monochromatic lights (RGB)

•Each object has a collection of material properties which determine how it reflects light

Diffuse Reflection

•Lambert’s Law: The reflection from a perfectly matte surface is proportional to the dot product of the surface normal and light vector

idiff = (n•l)mdiff ⊗ sdiff

Specular Reflection

•Not all materials are perfectly matte, and shiny objects tend to reflect primarily along the reflected light vector

ispec = (v•r)mshi mspec ⊗ sspec

Ambient Reflection

•Sometimes light reaches an object indirectly (e.g., from bouncing off walls in the scene)

iamb = mamb ⊗ samb

Emission

•Sometimes a surface might represent a light

•Note that emissive surfaces do not light other objects

iem = mem

Putting it Together

•The materials model used by most graphics systems isn’t necessarily physically accurate

•However, it provides a enough control to the programmer for most any effect

itot = idiff + ispec + iamb + iem

Transparency

•Typically implemented with a color buffer

•Unless objects are rendered back to front, pixels can get incorrect colors

cnew = αsrccsrc + (1-αsrc)cdest

http://en.wikipedia.org/wiki/Image:Butterfly_transparent.jpg

Shading Techniques

Flat Gouraud Phonghttp://www.cs.cmu.edu/~ph/nyit/facet_gouraud_phong.jpeg

Shading Comparison

•Flat shading is very fast, but looks blocky

•Phong shading looks great, but is difficult to compute

•Gouraud shading offers a balance of speed and quality