Pro OpenGL ES for iOS

(singke) #1

212 CHAPTER 7: Well-Rendered Miscellany^


Figure 7-4. Lens flares are caused by the inner reflections of a bright light source within a camera’s lens.

Since flare images are 2D, how do we put them in a 3D space? Going back to the
original sample, the bouncy square was also 2D object. But displaying it relied on some
defaults as to how the object was mapped to the screen. Here we get a little more
specific.
Remember in Chapter 3, where I spoke of perspective vs. orthographic projections? The
former is the way we perceive the dimensionality of objects; the latter is used when
precise sizes and shapes are required, eliminating the distortion that perspective adds to
the scene. So, when drawing 2D objects, you will generally want to ensure that their
visual dimensions are untouched by any of the 3D-ness of the rest of your world.
When it comes to generating your lens flares, you will need a small collection of different
shapes to represent some of the mechanics of the actual lens. The hexagonal or
pentagonal images are those of the iris used to vary the intensity of the incoming light;
see Figure 7-5. They will also exhibit different tints as a result of the various coatings
used to protect the lenses or filter out unwanted wavelengths.
Free download pdf