Honours Graphics 2008

19
Honours Graphics 2008 Session 4

description

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. - PowerPoint PPT Presentation

Transcript of Honours Graphics 2008

Page 1: Honours Graphics 2008

Honours Graphics 2008

Session 4

Page 2: Honours Graphics 2008

Today’s focus

• Colors

• Vertex coloring

• Gourad and Phong lighting

• Problems with transparency

Page 3: Honours Graphics 2008

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

Page 4: Honours Graphics 2008

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

Page 5: Honours Graphics 2008

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.

Page 6: Honours Graphics 2008

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

Page 7: Honours Graphics 2008
Page 8: Honours Graphics 2008

Vertex coloring

• Both DirectX and OpenGL allow the specification of vertex coloring. The colors specified are then blended across the vertices

Page 9: Honours Graphics 2008

Vertex coloring, cont.

• When tris are textured, the result can be modulated with the computed vertex coloring

Page 10: Honours Graphics 2008

Vertex coloring, cont.

• Vertex coloring can be used in a variety of useful ways; such as implementing coarse shadows in terrain:

Page 11: Honours Graphics 2008

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

Page 12: Honours Graphics 2008

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

Page 13: Honours Graphics 2008

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

Page 14: Honours Graphics 2008

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

Page 15: Honours Graphics 2008

Phong illumination model

• Describes reflections through ambient, diffuse and specular components

Image curtesy wikipaedia

Page 16: Honours Graphics 2008

Phong shading

• Improves on Gouraud shading, instead of interpolating colors it interpolates normals which are then used with the Phong illumination model

Page 17: Honours Graphics 2008

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

Page 18: Honours Graphics 2008

Transparency problem, cont.

• The solution is to ensure they’re rendered from back to front

• Hardware may eventually automate this

Page 19: Honours Graphics 2008

Homework

• Implement the ROAM terrain algori--- nah, I’m kidding, no homework today