multiple texturing

I’m writing a basic planet viewer OpenGL application, just for fun. I have the basics working, with the glorious planet, implemented through a gluSphere(), rotating with the classic earth texture map applied.

Now, what if I want to apply a second texture map through OpenGL (say, the “earth clouds”)?

The earth texture is a color image and the cloud texture is a grey-level image. I want the final result to be like cloud floating above the earth.

I tried use different texture environment, but the earth texture is always hidden by the cloud. Which environment parameter should I choose?

Specifically, How should I setup your glTexEnvf calls?

I am not sure if gluSphere supports multi-texturing. I rolled my own sphere code, and use shaders for multi-texturing.

But basically for the FF pipeline this is what you need to do…

glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, earthTex);
glTexEnvf(GL_TEXTURE_ENV, …, …);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, cloudTex);
glTexEnvf(GL_TEXTURE_ENV, …, …);

I would put GL_REPLACE in the first TexEnv and GL_BLEND in the second and see how it looked, and then go from there…
The options are fairly well documented here…
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/texenv.html

Here’s a useful page on some ways of combining textures…
http://www.opengl.org/wiki/Texture_Combiners
An example in GLSL is underneath the FF pipeline commands, which might tempt you to look into shaders… :slight_smile:

Alternatively send two spheres, the second slightly larger than the first, and have the clouds on the second one.

In the end this is how I do my clouds as I then have some parallax between the clouds and the ground, and can blend cloud shadows onto the ‘earthtex’ sphere…

Thank you. Very helpful.

Also, if you happen to have a copy of the orange book, chapter 10 has some great examples of using multitexturing for rendering the earth: night lights on the dark side of the globe, gloss maps for the ocean, etc. Their examples use shaders but are still straightforward.

Patrick

I tried this approach but did not succeed. I am very new to OPenGL. If I set the second sphere translucent, it seems to me the first sphere is not shown, while the back sides of the second sphere shows when the sphere rotates.

Should I use the some culling method to get ride of the back side when the ball is rotating? Is there any there easy implementation that solves the problem? Or can you give more details on your approach of using two spheres? Thank you.