Graphics Reference
In-Depth Information
How it works…
By changing the texture properties in the DGSL file to Public Access, we make the
corresponding texture properties visible within the 3D Scene ( .fbx ) graphics editor.
The Visual Studio graphics content pipeline will then convert the assigned textures to DDS
textures, and copy them to the output directory along with the compiled mesh ( .cmo ) file.
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 completed mesh renderer class from
Chapter 4 , Animating Meshes with Vertex Skinning .
We will be using a number of new models along with some new textures. These assets are
available with the completed project in the companion download. The completed version
of this recipe is available from the companion code as Ch06_01DisplacementMapping .
These models also require the use of MultipleTextures.dgsl that we created in the
previous Referencing multiple textures in a material recipe with the Visual Studio graphics
content pipeline.
To add the models for this recipe, follow these steps:
1.
With the Visual Studio shader graph MultipleTextures.dgsl in place, we can
add the new 3D scenes from the downloaded content. Go ahead and add Cube.
fbx , Plane.fbx , and Tree.fbx along with their textures to the root of our
project directory. The *.fbx files need to be included in the project, and have the
MeshContentTask applied as explained in Chapter 3 , Rendering Meshes .
 
Search WWH ::




Custom Search