To prepare ourselves for materials and lighting, we will include a normal vector in our vertex structure. The normal vector is a vector that indicates what direction is perpendicular to a tangent on the surface of the object. For each fragment in the pixel shader, we can use the normal vector to determine the angles between the viewer, light source, and surface. This value is necessary so that we can calculate the impact of lighting.
For rendering our cube and sphere, we will first prepare ourselves by following the ensuing steps:
Begin by adding a new Direct3D project to our solution.
Prepare the new project for rendering as per the Rendering primitives recipe in Chapter 2, Rendering with Direct3D, remembering to add the necessary references and to add the build event...