Adding surface detail with normal mapping

Normal mapping allows us to perturb normal vectors so that the light bounces from the surface in the correct direction, making the appearance of additional detail on the surface where otherwise there is not. We have already added support for loading multiple textures for a mesh, both in the MeshRenderer class in the Loading a static mesh from a file recipe in Chapter 3, Rendering Meshes, and within models in the previous recipe Referencing multiple textures in a material with the Visual Studio graphics content pipeline. Now, we need to update our shaders to sample the normal map and calculate the final normal direction.

Here, we will update the vertex structure and shaders to support passing a vertex's ...

Get Direct3D Rendering Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.