Time for action – HLSL declarations
1. Update the declarations area of the
Terrain.fx
file (at the very top of the file) to include a declaration for the texture we will be passing to the effect. The section should now read:float4x4 World; float4x4 View; float4x4 Projection; texture terrainTexture1; sampler2D textureSampler = sampler_state { Texture = (terrainTexture1); AddressU = Wrap; AddressV = Wrap; };
What just happened?
At the top
of the default file that is generated when we add a new effect to our project, three variables of the type float4x4
are declared for us. These variables have familiar names, World
, View
, and Projection
. If you think back to our discussion on matrices, an XNA matrix is a 4 by 4 array of float values, so the HLSL type float4x4
corresponds to an XNA matrix. In fact, these are the variables in the effect file that we set when we use the Parameters[].SetValue()
method in our draw code.
We add the terrainTexture1
variable here, declaring it as type texture...