190 likes | 262 Views
Honours Graphics 2008. Session 4. Today’s focus. Colors Vertex coloring Gourad and Phong lighting Problems with transparency. Colors. A great variety of color models exist, such as CIE XYZ, HUV, Lab, RGB, etc.
E N D
Honours Graphics 2008 Session 4
Today’s focus • Colors • Vertex coloring • Gourad and Phong lighting • Problems with transparency
Colors • A great variety of color models exist, such as CIE XYZ, HUV, Lab, RGB, etc. • Stems from work that demonstrated that human eye senses three color spectrums, namely red, green and blue • Green appears brightest, while human eyes are most sensitive to variation in blue
Colors, cont. • The premise of color spaces is the realization that a triplet of values is sufficient to uniquely describe a color • Computers normally make use of RGB color space – as it is simple and thus easily implementable in hardware
RGB • In RGB each color is defined by three components that represent the red, green and blue weighting of the color • Typical for modern computers is making use of 8bits per color channel allowing for a 24bit description of color – equivalent to 2^24 = 16 777 216 distinct colors.
RGB, cont. • In 24bit RGB each color component can vary in value between 0 and 255 • Imaging programs, and modern graphics hardware, typically normalize the colors to a range between 0 and 1 • This allows imaging and color computations independent of the color depth
Vertex coloring • Both DirectX and OpenGL allow the specification of vertex coloring. The colors specified are then blended across the vertices
Vertex coloring, cont. • When tris are textured, the result can be modulated with the computed vertex coloring
Vertex coloring, cont. • Vertex coloring can be used in a variety of useful ways; such as implementing coarse shadows in terrain:
Vertex coloring, cont. • Another example, particle systems may make use of generic white textures and color the particle using vertex coloring • Any continuous, area covering shading can be implemented in vertex colors, such as infra-red display
Lighting models • Displaying an object with some degree of accuracy requires a convincing use of light and shadow • This in turn requires some underlying lighting model to approximate the behavior of light, such as the Gouraud and Phone lighting models Image curtesy wikipedia
Gouraud • Henri Gouraud, published 1971 • Obtain vertex normals by averaging normal of polygons meeting at vertex • Compute lighting via Phong reflection • Bi-linear interpolation of color values at vertices • Essentially “free” in modern graphics hardware due to vertex coloring
Phong • Bui Toung Phong, published 1973 • Distinguish between Phong illumination and Phong shading • Phong illumination (also reflection or lighting) describes a model for light reflectivity • Phong shading (or interpolation) is better approximation to lightning than Gouraud shading
Phong illumination model • Describes reflections through ambient, diffuse and specular components Image curtesy wikipaedia
Phong shading • Improves on Gouraud shading, instead of interpolating colors it interpolates normals which are then used with the Phong illumination model
Transparency problem • Partial transparency is a useful tool for a wide variety of graphics effects (particle systems, windows, etc.) • A problem exists with transparency order though: if multiple transparent areas overlap, then the order in which they are rendered changes the result
Transparency problem, cont. • The solution is to ensure they’re rendered from back to front • Hardware may eventually automate this
Homework • Implement the ROAM terrain algori--- nah, I’m kidding, no homework today