Open GL Super Bible:Color and Shading
To access the contents, click the chapter and section titles.
Open GL Super Bible
(Publisher: Macmillan Computer Publishing)
Author(s): Waite group Press
ISBN: 1571690735
Publication Date: 08/01/96
Previous
Table of Contents
Next
Chapter 8Color and Shading
What youłll learn in this chapter:
How to
Functions Youłll Use
Specify a color in terms of RGB components
glColor
Set the shading model
glShadeModel
Create a 3-3-2 palette
CreatePalette
Make use of a palette
RealizePalette, SelectPalette, UpdateColors
At last we are going to talk about color! This is perhaps the single most important aspect of any graphics libraryeven above animation support. You must remember one thing as you develop graphics applications: In this case, the old adage isnłt true; looks ARE everything! Donłt let anyone tell you otherwise. Yes, itłs true that features, performance, price, and reliability are important factors when youłre selecting and working with a graphics application, but letłs face iton the scales of product evaluation, looks have the largest impact most of the time.
If you want to make a living in this field, you cannot develop just for the intellectual few who may think as you do. Go for the masses! Consider this: Black-and-white TVs were cheaper to make than color sets. Black-and-white video cameras, too, were cheaper and more efficient to make and useand for a long time they were more reliable. But look around at our society today and draw your own conclusions. Of course, black-and-white has its place, but color is now paramount. (Then again, we wish they hadnłt colorized all those Shirley Temple movies)
What Is a Color?
First letłs talk a little bit about color itself. How is a color made in nature, and how do we see colors? Understanding color theory and how the human eye sees a color scene will lend some insight into how you create a color programmatically. (If color theory is old hat to you, you can probably skip this section.)
Light as a Wave
Color is simply a wavelength of light that is visible to the human eye. If you had any physics classes in school, you may remember something about light being both a wave and a particle. It is modeled as a wave that travels through space much as a ripple through a pond; and it is modeled as a particle, such as a raindrop falling to the ground. If this seems confusing, you know why most people donłt study quantum mechanics!
The light you see from nearly any given source is actually a mixture of many different kinds of light. These kinds of light are identified by their wavelengths. The wavelength of light is measured as the distance between the peaks of the light wave, as illustrated in Figure 8-1.
Figure 8-1 How a wavelength of light is measured
Wavelengths of visible light range from 390 nanometers (one billionth of a meter) for violet light, to 720 nanometers for red light; this range is commonly called the spectrum. Youłve undoubtedly heard the terms ultraviolet and infrared; these represent light not visible to the naked eye, lying beyond the ends of the spectrum You will recognize the spectrum as containing all the colors of the rainbow. See Figure 8-2.
Figure 8-2 The spectrum of visible light
Light as a Particle
“OK, Mr. Smart Brain," you may ask, “If color is a wavelength of light and the only visible light is in this 'rainbowÅ‚ thing, where is the brown for my Fig Newtons or the black for my coffee, or even the white of this page?" WeÅ‚ll begin answering that question by telling you that black is not a color; nor is white. Actually, black is the absence of color, and white is an even combination of all the colors at once. That is, a white object reflects all wavelengths of colors evenly, and a black object absorbs all wavelengths evenly.
As for the brown of those fig bars and the many other colors that you see, they are indeed colors. Actually, at the physical level they are composite colors. They are made of varying amounts of the “pure" colors found in the spectrum. To understand how this works, think of light as a particle. Any given object when illuminated by a light source is struck by “billions and billions" (my apologies to Carl Sagan) of photons, or tiny light particles. Remembering our physics mumbo jumbo, each of these photons is also a wave, which has a wavelength, and thus a specific color in the spectrum.
All physical objects are made up of atoms. The reflection of photons from an object depends on the kinds of atoms, the amount of each kind, and the arrangement of atoms in the object. Some photons will be reflected and some will be absorbed (the absorbed photons are usually converted to heat), and any given material or mixture of materials (such as your fig bar) will reflect more of some wavelengths than others. Figure 8-3 illustrates this principle.
Figure 8-3 An object reflects some photons and absorbs others
Previous
Table of Contents
Next
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Wyszukiwarka
Podobne podstrony:
227 230223 227 6fcwctb2pglckpptczkjmjgfc6sdcxsk6lmqcji25 (230)28 (227)szczecin,komis m,227227 6ANNP2DZCVP3A27IUTN2JOADGP3CSMLWOHMKEKI225 230szczecin,firmy m,227więcej podobnych podstron