230 likes | 379 Views
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.
E N D
Graphics ReviewGeometry,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, yh, h) with h = 0 corresponds to point at infinity Homogeneous coordinate (xh, yh, 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
Matrix Properties Translation is additive Rotation is additive ...both are commutative Rotation matrices are orthogonal
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 graph / characteristic polygon Control points
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 http://en.wikipedia.org/wiki/Image:Butterfly_transparent.jpg cnew = αsrccsrc + (1-αsrc)cdest
Shading Techniques Flat Gouraud Phong http://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