cellShading color index?

Started by
13 comments, last by siddim 21 years ago
i just try to use the multitexturing stuff but (of course) i meet some problems:

http://www.thinbox.ca/_images/goliath/multiTex.jpg


the second texture, the 1d one, did''n seem to be used correctly, i change it and it still display the same way. Also the skybox is completly gone, i think it might be something i did''n disable correctly, but can''t find it. any idea?


glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D,ntexture[nTexID_]);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_1D,ntexture[n1DTexID_]);
Advertisement
You have to disable/enable texturing for each texture unit independently.
For instance this :

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_1D);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);

is not the same as this :

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_1D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);


For your code, you should enable texture 2D for texture unit 0 and texture 1D for texture unit 1, so :
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D,ntexture[nTexID_]);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_1D,ntexture[n1DTexID_]);
glEnable(GL_TEXTURE_1D);

Also, I hope you send texture coordinates with glMultiTexCoord1fARB for the second texture unit.

If your skybox does not render correctly anymore, I bet this is because you either don''t disable texturing for second texture nuit, or because you don''t activate the first texture unit.
In other words, after rendering your cel-shaded model, you should call :
glActiveTextureARB(GL_TEXTURE0_ARB);
vglDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_1D);
glActiveTextureARB(GL_TEXTURE0_ARB);

The last line is extremely important because, if you don''t call it, all texture bindings will be done to TEXTURE1_ARB. For instance, your skybox (which is textured obviously) will setup textures for the second texture unit, but will send coordinates for the first texture unit (because glTexCoord(coord) is the same as calling glMultiTexCoord(GL_TEXTURE0_ARB, coord)).

Hope this helps.
nice, it almost works, the model is rendered correctly and the sky box is well rendered also except that it seem that the multitexturing is still active when it displays the sky box. Therefore our second texture (shader) is displayed on top of the skybox.

How do we disable the second texture?
If the second texture is 2D, call that :

glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);

If it is 1D, call that :
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_1D);

Either way, it is very important to call this line just after one of the two disable above, so that the first texture unit becomes the current one :
glActiveTextureARB(GL_TEXTURE0_ARB);
work prefectly now, thanks alot vincoof.

This topic is closed to new replies.

Advertisement