environment mapping over a texture


it’s me again, I don’t know how I can draw a mesh with environment mapping and a texture over or vice-versa, do I need to use multi-texturing? Is there any examples, or source available on a URL?



Two Possibilities:

  1. Non-Multitexturing

Draw The Object with The Surface Texture applied.

Next, Draw Again the same Object With the Environment Map on it.

When doing this however, you must do one of two things first…

You Must Change the Depth Test to GL_LEQUAL to allow you to draw in exactly the same space. Second, you’ll need to set up blending with a function of GL_ONE,GL_ONE to Blend them in equal portions.

The code will look like…

glBindTexture(GL_TEXTURE_2D, Surface_Texture);


// Enable Sphere or Cube Mapping here…

glBindTexture(GL_TEXTURE_2D, Environment_Map);

// Disable Sphere or Cube Mapping Here…


  1. The Multitexturing Method

//Set Up your two texturing units…


// Enable Cube Or Sphere Mapping Here…

// Then Draw Your Object

Bear in mind that if you are making openGL work out the texturing co-ords for you, then you can just use glTexCoord*(); to specify your texturing co-ords for the first texturing unit. The only problem with using multitexturing for doing this, is that you will not get as much control as you would with multiple rendering passes. Some openGL drivers also find this kind of thing a bit too hard to handle.

If you have a Geforce series of card, it may pay to look at the register combiners to speed things up and give you back the control of multiple passes.

If you want to take things a wee bit further, you can add an alpha channel to the surface texture. When doing the second pass, try using:


This will draw the environment map only in places where the alpha channel of the texture has a value of 1, Thus giving you a very crude form of gloss mapping…