glEnable(GL_TEXTURE_2D);
…
draw some stuff
…
glDisable(GL_TEXTURE_2D);
…
draw some more stuff
…
However, the entire scene is textured. Without binding an all white texture when I want parts of my scene to ‘not be textured’, how do I do this?
Are there glsl commands equivalent to glIsEnabled so that I could branch as needed
…
if (glIsEnabled(GL_TEXTURE_2D)){
gl_FragColor = gl_Color * texColor;
}else{
gl_FragColor = gl_Color;
}
…
Or is there some other preferred way?
Any help is appreciated. Thank-you.
The prefered way as far as I know is to bind another shader which does not perform texturing ( or to completly disable shaders )
So it can look like this:
bind your texturing shader
…
draw some stuff
…
disable shaders or bind other shader
…
draw some more stuff
Of course you can do this by branching inside the shader ( for example by passing some uniform variable to the shader which determines if the texture look-up should be done ). However branching is still quite slow on the GPU ( especialy in fragment shader since its SIMD )
Originally posted by Zulfiqar Malik: I have never tried this, but you could set the sampler handle to 0.
Im not sure if I understand you correctly but setting the sampler to 0 means that you are reading a texture from the texture unit 0 so it would probably not help him much.
Thanks for the replies. Enabling/disabling the shaders with glUseProgramObjectARB produced the desired results.
As a seperate question (too minor to start a new post), is it possible to use more than one shader program object at once. Example - a shadow map and a texture shader. Is it more/less desirable to seperate shaders when possible or to combine in a larger program, or is it just personal preference?
1.Only one shader can be active in given time.
2. On current hardware its usualy better to create separate shaders for most things ( it depends what you want to do ). I think that there are a lot of threads about this topic on this forum so you can find more detail when its better to create a new shader and when its possible to reuse an old one there.
and of course, this is where modular programming comes in - GLSL supports multiple source files, which you can combine to create specialised shaders simply by plugging your library of functions together in a specific way.