PDA

View Full Version : Multitexture and Reflections



amerio
11-17-2000, 01:57 PM
To begin with, I know how to use multitexturing to produce lightmapped textured polygons.
What I'm trying to do is making lightmapped textured polygons PLUS reflection mapping.

For now, I'm doing this:
glDisable(GL_LIGHTING);
// colormap
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, colormap);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_RE PLACE);
// lightmap
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, lightmap);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MO DULATE);
// reflectionmap
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, reflectionmap);
glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,CGL Vector(1,1,1,1));
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_BL END);

(okay, some lines are missing, but you got the idea)

Without the 'reflectionmap' section, everything is correct (ie a superb greyish cub with a lighting gradient on it)

But with the 'reflectionmap', I see a full illuminated cube with a reflection map.
The lightmap vanished ??????

I read and read again all the specs I could find. Tuned all parameters I could of... No way...

Save me !!!! Help !!! glub glub glub (sinking)

j
11-17-2000, 03:54 PM
Just a guess, but most graphics cards support only 2 textures at once. That could be the cause of the problem.

Or it could be because of the way you are using the blend mode on the final texture.

I'm not sure, but I think that the GL_BLEND texture blend mode modulates the current texture with a constant color and then applies it. This would mean that you are modulating your reflection map with the color white and then applying it on top of the other textures, which would look the same as what you describe. Even if it modulates the texture by the blend color and then blends the result with the previous texture, using a alpha value of 1 would still mess that up (I think).

Maybe try to put the transparency into the reflection map as an alpha channel set to about 50% transparency, and use the GL_DECAL texture environment.

amerio
11-18-2000, 10:51 AM
ACtually, I have a GeForce2/64M, so it should
have 4 Textures Unit, so I think this is not the problem.

For the TEX_ENV mode, I tried with DECAL, BLEND, REPLACE (just to say : I tried), even tried with GL_ADD (as ARB_texture_env_add is supported). No way !

I searched for some example code, but all tutorials are showing the easy lightmap (2 texture units only).

I'll try with the transparency trick...

Won
11-18-2000, 11:29 AM
The GeForce2 only has two texture units. It has four pixel pipelines for it's per-pixel shading.

-Won

amerio
11-19-2000, 07:29 AM
Gulp. Okay. My fault.

So, I'll have to get back to multi-pass, I guess... http://www.opengl.org/discussion_boards/ubb/frown.gif

Thanks for the input !

Roderic (Ingenu)
11-20-2000, 07:47 AM
Having only 2 TMU doesn't prevent you to do 100 texture pass on a given polygon...