Time for action – multitexturing
1. In the declarations area of the
Terrain.fx
effect file, add two new texture variables to hold the additional textures we will be using, as follows:texture terrainTexture2; texture terrainTexture3;
2. Still in the declarations area, add samplers for the new textures as follows:
sampler2D textureSamplerMid = sampler_state { Texture = (terrainTexture2); AddressU = Wrap; AddressV = Wrap; }; sampler2D textureSamplerHigh = sampler_state { Texture = (terrainTexture3); AddressU = Wrap; AddressV = Wrap; };
3. Also in the declarations area, add the following items to control how the textures are split between elevations:
float maxElevation; float trans1 = 0.50; float trans2 = 0.75;
4. In the
VertexShaderOutput
structure, add a new structure member to allow us to pass the elevation of the current vertex to the pixel shader as follows:float Elevation : TEXCOORD1;
5. In the
VertexShaderFunction()
method, right after declaring the output variable, store the...