In this recipe, we will be creating a displacement decal in order to add dynamic detail to a mesh on the GPU in real-time. This technique combines hardware tessellation and displacement to implement local mesh deformations such as footsteps, bullet holes, and craters.
We are using three new textures that are available in the downloaded content for this recipe,
Crater_Normal.png. The completed project can be found in the companion code
We will begin by creating our new
Shaders\CommonDecal.hlsl HLSL shader file. This will introduce a new constant buffer to hold the necessary information that will be applied to our decal, include the texture references we need, and house the functions to calculate our decal's displacement:
First, create a new HLSL file,
Shaders\CommonDecal.hlsl; be sure to change the encoding or copy an existing HLSL file and clear the contents...