Book Image

Direct3D Rendering Cookbook

Book Image

Direct3D Rendering Cookbook

Overview of this book

Table of Contents (19 chapters)
Direct3D Rendering Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Further Reading
Index

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 tangent vector from the loaded mesh in order to calculate the new normal direction. We also look at the changes necessary to support normal mapping within the tessellation pipeline if that is in use.

Getting ready

In this recipe, we will begin with the...