Chapter 4
Turning On the Lights
You must be strong now. You must never give up. And when people [or
code] make you cry and you are afraid of the dark, don’t forget the light
is always there.
-----Author Unknown
Light is the first of painters. There is no object so foul that intense light
will not make it beautiful.
-----Ralph Waldo Emerson
Everything’s shiny, Cap’n. Not to fret.
-----Kaylee Frye, Firefly
This chapter will cover perhaps the single biggest topic for OpenGL ES: the process of
illuminating, shading, and coloring the virtual landscape. We touched on color in the
previous chapter, but because it is so integral to both lighting and shading, we will cover
it more in depth here. For those of you reading the quaint paper version of this book,
yes, I know, it is odd to have a chapter on colors in a monochrome form. However, the
ebook version is in color.
The Story of Light and Color
Without light, the world would be a dark place (duh). Without color, it would be hard to
tell the difference between stoplights.
W e a l l t a k e f o r g r a n t e d t h e w o n d r o u s n a t u r e o f l i g h t -----from the soft and gentle
illumination off the morning mist to the ignition of a space shuttle’s main engines to the
shy pale radiance of a full moon on a snowy field in mid-winter. A lot has been written
about the physics of light and its nature and perception. It might take an artist a lifetime