
We can define this mapping on a per-triangle basis, by specifying which points of the texture should go on each vertex of the triangle (Figure 14-2). Next, we need to specify how this texture is applied to the model. Figure 14-1: Wooden crate texture (by Filter Forge- Attribution 2.0 Generic (CC BY 2.0) license) Figure 14-1 shows a wooden crate texture.

Since we know how to deal with geometry, we’ll explore the second option.įirst, we need an image to paint on our triangles in this context, we call this image a texture. Note that the two options aren’t incompatible: you can choose the right balance between adding geometry and painting on that geometry to achieve the image quality and performance you require. Unless you’re looking at the crate from up close, you won’t notice the difference, and the computational cost is significantly lower than adding lots of geometric detail. This would work, but it would add a lot of geometric complexity to the scene, resulting in a big performance hit.Īnother option is to fake the details: instead of modifying the geometry of an object, we just “paint” something that looks like wood on top of it. How do we turn a cube into a wooden crate? One option is to add a lot of triangles to replicate the grain of the wood, the heads of the nails, and so on. Let’s say we want our scene to have a wooden crate. In this chapter, we’ll look at how we can add visual detail to the surface of our objects by using textures.

But we usually don’t want to render abstract geometric objects like cubes and spheres instead, we want to render real-world objects, like crates and planets or dice and marbles. Our rasterizer can render objects like cubes or spheres.
