PDA

View Full Version : Using TexUnv without Textures



Corrail
11-30-2003, 04:44 AM
Hello!

I've got the following problem:
I want to use the TexEnv of a Texture Unit without a texture but I'm afraid of performance loss:


glActiveTexture(GL_TEXTURE0);

glBindTexture(GL_TEXTURE_CUBE_MAP, NormCubeMap);

glEnable(GL_TEXTURE_CUBE_MAP);


glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);

glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0, GL_TEXTURE0);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1, GL_TEXTURE1);


glActiveTexture(GL_TEXTURE1);

glBindTexture(GL_TEXTURE_2D, Bump);

glEnable(GL_TEXTURE_2D);


glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);

glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0, GL_PREVIOUS);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1, GL_PREVIOUS);


glActiveTexture(GL_TEXTURE2);

glBindTexture(GL_TEXTURE_2D, nomap);

glEnable(GL_TEXTURE_2D);


glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);

glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0, GL_PREVIOUS);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1, GL_PREVIOUS);


Here I use Texture Unit 2 only for taking the square of Texture Unit 1. But if I disable textureing the Texture Environment won't work. But how can I use this Texture Unit only for Texture Env. I don't pay the cost of sampling a texture here...

Thanks for any help!

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081

jwatte
11-30-2003, 07:51 AM
In the OpenGL model, the texture unit has to be enabled for the texture environment to apply. That's a limitation of the fixed-function pipe.

If you don't actually read from the second texture, you can either bind a 4x4 white texture on that unit, or make it invalid to force it to source white; you'd have to benchmark which solution is faster on which card.

Corrail
11-30-2003, 07:53 AM
Okay, thanks. I'll try that!