Multi-texture mixing technology is widely used in terrain rendering, used to mix very different multiple textures (such as stones and grass), can't see obvious edges. For example, you can use 3 textures (stones, grass and sand) to render a mountain, mix in the bottom of the mountains and sand. Multi-texture mix is expanded in OpenGL through ARB_MULTITEXTURE and ARB_TEXTURE_ENV_COMBINE. Divided into the following steps: 1. Calculate 3 textures of each contribution, and encode them into the colors of the vertex, such a color RGB portion controls the interpolation between the texture stages 0 and 1, the color of the alpha control texture phase 1 and 2 interpolation. 2. Use GL_ARB_MULTITEXTURE to simultaneously apply 3 textures simultaneously to the surface of the object. 3. Set the first texture to the texture phase 0. 4. In the Texture Phase 1, use GL_INTERPOLATE_ARB to perform linear interpolation between the output of the texture phase 0 (the first texture) and the texture of the phase 1. 5. In the Texture Phase 2, use GL_InterPolate_arb to perform a linear interpolation between the output of the texture phase 1 (the mixture of the first texture and the second texture) and the texture of the stage 2. Interpolation. Typical code is: GLTEXENVI (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); GLTEXENVI (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB);
GLTEXENVI (GL_TEXTURE_ENV, GL_SOURE0_RGB_ARB, GL_PREVIOUS_ARB); // The front texture phase GLTEXENVI (GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
GLTEXENVI (GL_TEXTURE_ENV, GL_SOURE1_RGB_ARB, GL_TEXTURE); // Current texture GLTEXENVI (GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB); // Color group glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR); // or GL_SRC_ALPHA prior to use, first stage system allows to view the number of texture: int nTextureUnits = 0; glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, & nTextureUnits ); This technique is more complicated, and now you can use Shader to achieve, simple, but in order to take care of old graphics cards, this technology is still very common.