Chapter 27. 3D lighting, texturing, and animation
This chapter covers
- Effects, lighting, and normal vectors
- Texturing objects
- Coordinate spaces and matrices
- Keyframe animation
In the previous chapter, you modeled a sphere and rendered it in 3D. You could tell it was 3D due to the curvature of the bands, but it wasn’t nicely shaded, and it definitely wasn’t lit. A key part of what makes a rendering convincing as 3D is the lighting.
In DirectX-based 3D systems, lighting is handled by various shaders. These shaders, which run directly on the video card, are small, high-performance algorithms that anyone can write. In XNA, a DirectX-based system, the shaders are encapsulated in a class derived from the Effect class. Throughout this chapter (as you did in chapter 26), you’ll use the BasicEffect class. This class’s name is a bit misleading because it can do so very much for you.
As part of the lighting effect discussion, I’ll also show you another way to tessel-late spheres. This version works better for lit and textured shapes, and it also uses a new way of representing the shapes: an indexed vertex list.