PDA

View Full Version : Turn off multiple texture units



Itun.itu
04-18-2011, 01:42 PM
I use multitexturing in my shader. Then I turn off shader and render the second part of the scene. How to turn off multiple texture units because they influence to other render parts. I activate my them:


glActiveTexture(GL_TEXTURE0 + index);
glBindTexture(GL_TEXTURE_2D,
((MaterialSampler2D)specular).texture.getTOB());
shader.setTexture2(index);

Is there something like glDeactivateTexture?

mhagain
04-18-2011, 02:19 PM
Try:
glActiveTexture(GL_TEXTURE0 + index);
glDisable(GL_TEXTURE_2D);
for each texture unit you wish to switch off.

Depending on your usage requirement you may find it easier to leave them all enabled, set the glTexEnv on the last texture unit to GL_REPLACE, and just use that for everything. Personally I'd rewrite the second pass to use shaders too.

Alfonse Reinheart
04-18-2011, 02:55 PM
I use multitexturing in my shader. Then I turn off shader and render the second part of the scene. How to turn off multiple texture units because they influence to other render parts.

You can bind the texture 0 there, but it won't really help.

Your shader will read from whatever texture units it is told to read from. So if you have a sampler in your shader, and you set the sampler to read from texture unit 0, then you will need to have a texture bound to texture unit 0.

If textures are influencing "other render parts," it is only because your shader is reading from those textures. The only way to change this is to change what texture unit the shader uses for a particular sampler.


Try:

Shaders don't care about the enable/disable state of texture units. Shaders only care about what texture object is bound to them.


set the glTexEnv

He's using shaders, not the texture environment.

mhagain
04-18-2011, 03:51 PM
Ahem:
Then I turn off shader and render the second part of the scene
He's most explicitly NOT using shaders for the second part of the scene that the question is actually about. Hence my reply.

Alfonse Reinheart
04-18-2011, 04:03 PM
He's most explicitly NOT using shaders for the second part of the scene that the question is actually about. Hence my reply.

Fair enough.