Pro OpenGL ES for iOS

(singke) #1

210 CHAPTER 7: Well-Rendered Miscellany^


This differs from the previous version of drawInRect() as follows:

„ In line 1 we need to change the square dimensions of the ‘‘square’’ to
compensate for the short but wide shape of the sun’s texture
geometry; otherwise, the image would be highly distorted.
„ Line 2 disables the lighting so that the full image can be seen no
matter what.
„ Lines 3f were commented out to turn off the coloring, making the
image of Hedly more visible.
I hope you get something like Figure 7-2, with Hedly bouncing up and down on the sun.

Figure 7-2. Using an off-screen FBO to animate texture on another one

Pretty slick, eh?

Lens Flare


We’ve all seen it. Those ghostly, glowing gossamer lights dancing around television
scenes or invading an image whenever a camera is aimed toward the sun. This happens
as the sun’s light merrily bounces around to and fro in the camera’s optics, causing
numerous secondary images. These can be seen both as a bright broad haze and as
many smaller artifacts. Figure 7-3a illustrates this with an image from the Apollo 14
moon landing mission in 1971. The flare obscures most of the lunar module. Even the
iPhone has the similar issues, as demonstrated with Figure 7-3b. Even though the
Hasselblad cameras that were used on the moon were the best in the world, we couldn’t
beat lens flare. Unfortunately, it has become one of the more common clichés in
computer graphics, used as a tool that shouts ‘‘Hey! This is not a fake computer image,
because it has lens flare!’’ However, lens flares do have their uses, especially in the
arena of space simulations because the fake imagery frequently looks at the fake sun. In
that case, both consciously and subconsciously, you’d expect some visual cue that you
were looking at something very, very, very bright. It also helps give an extra sense of
depth to the image. The flare is generated in the optics that are really near the user while
the target is a bazillion miles away.
Free download pdf