Pro OpenGL ES for iOS

(singke) #1

CHAPTER 10: OpenGL ES 2, Shaders, and... (^335)
Figure 10-8. Hedly and his friends. They’re a quiet bunch.
So, how is a cube map used? First, get used to adding a third component to the texture
coordinates, which specifies the face of the cube to use. Cube mapping makes a
number of assumptions:
„ The environment in the reflection very far away, so no parallax will be
visible.
„ The discontinuities are largely difficult to notice unless you know what
you’re looking for.
„ The object cannot reflect any part of itself, unless you use some
special image maps to compensate.
„ You have a curved surface, because cube maps don’t look right in a
flat surface like a mirror.
To draw an object with a reflection/cube map, OpenGL will draw a ray from your
viewpoint, bounce it off the target, and figure out where it hits on the cube map. The
intersection point on the object specifies what texture coordinates are to be used, and
the intersection on the cube map picks out what texel to use and which of the six faces
was hit.

Free download pdf