Sign in to follow this  
glmisscelan

Multitexturing problem

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...^^'

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites
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[i].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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this