Pro OpenGL ES for iOS

(singke) #1

CHAPTER 6: Will It Blend? (^191)
And similarly you’d use GL_SOURCE1_RGB for Arg1.
Table 6-3. Possible Values for GL_COMBINE_RGB and GL_COMBINE_ALPHA Parameters
GLCOMBINE Function
GL_REPLACE Arg0
GL_MODULATE Arg0
Arg1 (the default)
GL_ADD Arg0 + Arg1
GL_ADD_SIGNED Arg0 + Arg1-0.5
GL_INTERPOLATE Arg0 Arg2 + Arg1 (1-Arg2)
GL_SUBTRACT Arg0 – Arg1
GL_DOT3_RGB 4(((Arg0red-.5)(Arg1red-.5))+((Arg0green-.5)(Arg1green-.5))+
((Arg0blue-.5)
(Arg1blue-.5))) (GL_COMBINE_RGB only)
GL_DOT3_RGBA Same as above, but with alpha added (GL_COMBINE_RGBA only)
Mapping with Bumps
You can do many extremely sophisticated things with textures; bump mapping is just
one. So, what follows is a discussion of exactly what ‘‘bumps’’ are and why anyone
should be concerned with mapping them.
As previously pointed out, much of the challenge in computer graphics is to make
complicated-looking visuals using clever hacks behind the scenes. Bump mapping is
just one of those tricks, and in OpenGL ES 1, it can be implemented with texture
combiners.
Just as textures were ‘‘tricks’’ to layer complexity to a simple face, bump mapping is a
technique to add a third dimension to the texture. It’s used to generate a roughness to
the overall surface of an object, giving some surprisingly realistic highlights when
illuminated. It might be used to simulate waves on a lake, the surface of a tennis ball, or
a planetary surface.
Roughness to an object’s surface is perceived by the way it plays with both light and
shadow. For example, consider a full moon vs. a gibbous moon, as shown in Figure 6-



  1. The moon is full when the sun is directly in front of it, and as a result, the surface is
    little more than varying shades of gray. No shadows whatsoever are visible. It’s not
    much different than you looking at the ground facing away from the sun. Around the
    shadow of your head the surface looks flat. Now, if the light source is moved to the side
    of things, suddenly all sorts of details pop out. Figure 6-13 (right) shows a gibbous moon
    that has the sun toward the left, the moon’s eastern limb. It’s a completely different
    story, isn’t it?

Free download pdf