Texture ing can be performed in two ways:
Ø
Load a created texture file and then apply the texture data.
Ø
The other is to calculate the texture content one by one in order, that is, we first create an "empty" texture, and then calculate the color of the texture element based on some defined parameters. In terrain rendering, this parameter is the height of the terrain.
This method is first used
D3dxcreatetexture
Create an empty texture, and then lock the top texture (because there are multiple layers of texture. Now, we start to traverse each texture element and color it. The color is based on the approximate height of the coordinate square. The idea is: the lower part of the terrain is colored as the beach, the middle part is colored as the green hill color, and the high part is colored as the snow mountains. We use the height value of the vertex in the upper left corner of the coordinate square to represent the overall height of the square.
After coloring each texture element, we can adjust the brightness of each texture element based on the incident angle when the sunlight (simulated by direction light) reaches the coordinate square corresponding to the texture element.