Chapter 4. Using Textures
In this chapter, we will cover:
- Applying a 2D texture
- Applying multiple textures
- Using alpha maps to discard pixels
- Using normal maps
- Simulating reflection with cube maps
- Simulating refraction with cube maps
- Applying a projected texture
- Rendering to a texture
- Using sampler objects
Introduction
Textures are an important and fundamental aspect of real-time rendering in general, and OpenGL in particular. The use of textures within a shader opens up a huge range of possibilities. Beyond just using textures as sources of color information, they can be used for things like depth information, shading parameters, displacement maps, normal vectors, or other vertex data. The list is virtually endless. Textures are among the most widely used tools for advanced effects in OpenGL programs, and that isn't likely to change anytime soon.
Note
In OpenGL 4, we now have the ability to read and write to memory via buffer textures, shader storage buffer objects, and image textures...