JavaScript EditorFree JavaScript Editor     Ajax Editor 

Main Page
  Previous Section Next Section


Multitexture-capable hardware has been very popular since the age of the 3dfx Voodoo2 card. Multitexture basically enables us to assign N texture coordinates to the same triangle, so we can render more than one texture in a single step. Additionally, we can specify different texture arithmetic functions, so we can control the way the different texture maps are combined.

Multitexturing is at the core of most advanced rendering algorithms, from light mapping to bump mapping. It is accessible from both OpenGL (it used to be an extension, but now is part of the standard) and as part of the core functionality in Direct3D. Let's first review how we can specify multitexture under both APIs. Under OpenGL, multitexture is declared as follows:

// layer 0
glActiveTexture (GL_TEXTURE0);
// here we would set texture combination parameters for layer 0

// layer 1: modulate incoming color+texture
// here we would set texture combination parameters for layer 1

// render geometry

We need to initialize each texture unit separately, enabling texture mapping and setting the texture map we want to use with each one. Notice how we reserve some space for the texture combination code. How will both maps be blended together? Obviously, it makes no sense to render both maps with no blending options at all. But because this is the subject of the next section, I prefer to keep the code simple and easy to follow.

Also, notice the changes at the geometry rendering stage. We need to set texturing coordinates for each texture unit separately, so different units can be mapping with different coordinates. Let's now examine how we can specify blending options for texture maps.

      Previous Section Next Section

    JavaScript EditorAjax Editor     JavaScript Editor