Multitexturing problem

Started by
5 comments, last by Gorax 18 years, 10 months ago
hi, I have a skybox in my bsp engine, until today i didnt use multitexturing for the bsp textures, today i implemented it. Bsp textures works perfect but the textures for the skybox looks horrible. I solved this loading the skybox textures with the multitexturing procedures. if you use multitex every texture must be loaded as it? is there any way to disable multitex to solve this? Thanks
Advertisement
I belive you can disable multitexture in the same way you enabled it, but that might cause a slow down from object to object, so I'd suggest if you're using multitexture for most of your objects then just use one multitexture unit for ones that would overwise not be multitexture objects.
Hi, thanks.

The function to enable it is glActiveTextureARB but i cant find the function to deactivate it, glDeactivateTextureARB or glDisableTextureARB doesnt work.

So i use only one multitexture unit.
Something like this:

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, texture_sky[BACK]);

But the texture seem like if i was changing the light every second. 8-S.

Thanks.
The first unit should be GL_TEXTURE0_ARB, is there a meaning in enabling GL_TEXTURE1_ARB instead GL_TEXTURE1_ARB... Rememebr that, using multitexturing, means enabling (or disabling) every unit, that is needed (or not needed but active)... so, if you draw an object with 2 textures, and later you'll need only one, you must disable the corrispective texture unit... but maybe you just knew that :P Moreover, the skybox is rendered after the whole scene or before? (What I wanted to know is if the texture unit for the skybox is enabled beofre others, or after... in the second case, if the texture is messed up, it's possibloe that there is a not needed texture unit active... Hopes this help...^^'
Hi,

The display code is somehting like this

skybox()
cam()
render_bsp()

////////////////////////////////////////////////////
First i used:

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, texture_sky[BACK]);

It doesnt work, every texture was black.

///////////////////////////////////////////////////////
After i used:

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, texture_sky[BACK]);

It works, but the texture seem like if i was changing the light every second.

///////////////////////////////////////////////////////
At the end i use

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, texture_sky[BACK]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, texture_sky[BACK]);

It works perfect. But i dont think that it be the best way to do it.

Any other posibility?

Help.


Are you using vertex arrays?
If so, you miss the glEnableClientState call... since you never spoke about VA, anyway I suppose you don't... this is the code I use in a test project to enable and use multitexturing... (it's C#)

for(int i=0; i<this.m_TextureCount; i++){	Gl.glActiveTexture(Gl.GL_TEXTURE0+i);	Gl.glBindTexture(Gl.GL_TEXTURE_2D,this.m_Textures.ID);	Gl.glEnable(Gl.GL_TEXTURE_2D);	Gl.glClientActiveTexture(Gl.GL_TEXTURE0+i); //This is required if using VertexArrays}


I do it for each object... obviusly it's not the best way, since for each object I need to enable and disable (if not textured) all units, but since it's a mere test, it's ok... a good way, AFAIK, is to sort your 3D entities depending on the texture they use... maybe can be useful to sort by tot textures *and* texture ID... so you could sort object from the one with less textures to the one with more ones, in every group, you can order by Texture ID... maybe there are better solutions though! :P
To disable the texture objects, re-activate the texture you want to disable (using glActiveTextureARB()), and disable the texture (glDisable(GL_TEXTURE_*D) (where * = 1, 2 or 3, depending on your texture object)).
Example:
glActiveTextureARB(GL_TEXTURE3_ARB);
glDisable(GL_TEXTURE_2D);

On another note, the textures should be disabled in the reverse order that they were enabled (if you enabled GL_TEXTURE0_ARB, and then enabled GL_TEXTURE1_ARB, you should disable GL_TEXTURE1_ARB first, then GL_TEXTURE0_ARB). This might not be necessary, but I had quite a few weird problems until I did that, at which point the problems disappeared (this should allow you to use 1 texture object).

If you're using VAs, take BladeWise's advice.

This topic is closed to new replies.

Advertisement