Implementing texture sampling
In this recipe we are going to take the quad and triangle renderers from the previous example and apply some texture using a shader resource view (SRV), a sampler state object, and changes to the shader program.
The final output from the example will look something like the following figure:
Getting ready
For this recipe, we will continue from where we left of in the Rendering primitives recipe.
There are two texture files included with the sample code that you will also need. Alternatively, you may use any BMP, JPG, PNG, or even DDS formats. For reference, the two textures used in this project are shown in the following figure:
How to do it…
For this recipe, we will first change the HLSL shader code to accept the SRV and sampler state. Then, we will update our renderers to use texture coordinates, load the textures, and bind the SRVs to the appropriate stages of the pipeline. To do so, follow...