Presentation is loading. Please wait.

Presentation is loading. Please wait.

Color and Shading Lecture 9 Mon, Sep 26, 2005.

Similar presentations


Presentation on theme: "Color and Shading Lecture 9 Mon, Sep 26, 2005."— Presentation transcript:

1 Color and Shading Lecture 9 Mon, Sep 26, 2005

2 The RGB Color System The three primary light colors are red, green, and blue. By mixing these three colors in various proportions, all colors can be made. red + green = yellow red + yellow = orange dark orange = brown etc. + = + =

3 The Color Monitor Each pixel of the color monitor is square consisting of three vertical bands: a red, a green, and a blue band. The color we perceive depends on how bright each band is. Each band can be set to a level from 0 to 255. 0 = darkest level 255 = brightest level

4 The Color Monitor Red Yellow Black Green Magenta White Blue Cyan

5 The Color Monitor Red Yellow Black Green Magenta White Blue Cyan

6 Mixing Colors Read Run

7 Gray Levels If we mix the colors together in equal amounts, we get a level of gray. (0.0, 0.0, 0.0) = black (0.2, 0.2, 0.2) = dark gray (0.5, 0.5, 0.5) = medium gray (0.8, 0.8, 0.8) = light gray (1.0, 1.0, 1.0) = white

8 Gray Levels The following graphic shows 16 levels of gray.

9 Gray Levels The following graphic uses hundreds of levels of gray.

10 Setting the Color The function glColor*() will set the brightness levels of the red, green, and blue bands of the pixel. glColor3i(int red, int green, int blue) red, green, and blue are ints from 0 to 255. glColor3f(float red, float green, float blue) red, green, and blue are floats from 0.0 to 1.0. glColor3fv(float color[ ]) color is an array of three floats (red, green, blue).

11 Setting the Color Read Run

12 Varying the Color Levels
Read Run

13 The Full Range of Colors
Read Run

14 Shading Shading refers to adding color to an object.
In OpenGL, we specify the colors only of the vertices of the polygon. OpenGL uses linear interpolation to determine the colors of the pixels within the polygon.

15 Shading For triangles, the interpolated are determined uniquely by the colors of the three vertices. For larger polygons, OpenGL will triangulate the polygon, then shade each triangle. If the effect is undesirable, then the programmer must do his own triangulation.

16 Shading Larger Polygons
Read Run

17 Shading Model OpenGL provides two shading models
Smooth shading (interpolation) Flat shading (no interpolation) Flat shading shades the interior with the color of one arbitrarily selected vertex. Almost always, the smooth shading model produces better results.

18 Flat Shading of a Polygon
Read Run


Download ppt "Color and Shading Lecture 9 Mon, Sep 26, 2005."

Similar presentations


Ads by Google