Pro OpenGL ES for iOS

(singke) #1

140 CHAPTER 5: Textures^


Figure 5-8. Distorting images can give a 3D effect on 2D surfaces.

Textures can also be tiled so as to replicate patterns that depict wallpaper, brick walls,
sandy beaches, and so on, as shown in Figure 5-9. Notice how the coordinates actually
go beyond the upper limit of 1.0. All that does is to start the texture repeating so that, for
example, an s of .6 equals an s of 1.6, 2.6, and so on.

Figure 5-9. Tiled images are useful for repeated patterns such as those used for wallpaper or brick walls.

Besides the tiling model shown in Figure 5-9, texture tiles can also be ‘‘mirrored,’’ or
clamped, which is a mechanism for dealing with s and t when outside of the 0 to 1.0
range.
Mirrored tiling repeats textures as above, but also flips columns/rows of alternating
images, as shown in Figure 5-10 (left). Clamping an image means that the last row or
column of texels repeats, as shown in Figure 5-10 (right). Clamping looks like a total
mess with my sample image but is useful when the image has a neutral border. In that
case, you can prevent any image repetition on either or both axes if s or v exceeds its
normal bounds.
Free download pdf