Hello.
I discovered some strange probs with multitexturing.
my setup:
-NO vertex shader (fixed function default)
-simple texture mixing in fragment shader
-only one tex-coord for both textures
-rendering unlit to fullscreen-quad
-all textures generated BEFORE any mutli-texture commands (eg all in stage GL_TEXTURE0)
-one texture is rendered as FrameBuffer before in a complex pass (which works completely on his own).
for debug, i split the two textures into different rgb channels, coloring one image yellow, the other blue:
uniform sampler2D Image;
uniform sampler2D Image2;
varying vec4 gl_TexCoord[];
void main(void){
vec2 tc=vec2(gl_TexCoord[0]);
gl_FragColor = vec4(texture2D(Image,vec2(gl_TexCoord[0])).xy,texture2D(Image2,vec2(gl_TexCoord[0])).x,1.0);
}
i allways fill in both sampler2D uniforms from GL constant by Image=0, Image2=1.
now following happens:
-if i do nothing multitexure commands in GL, only a yellow “Image” renders. correct.
-if i bind a second texture, preceded by glActiveTexture(GL_TEXTURE0+1), i only see it, “Image2”, tinted blue. NOT correct. Both textures should appear mixed.
-if i now exchange the sample-bindings; eg. Image=1; Image2=0 then only the new texture is rendered, now yellow. simple. so switched back.
-now for the very strange, hurray…
if i switch to glActiveTexture(GL_TEXTURE0+1) while my whole mainloop which renders to the FrameBuffer and therefore “Image”, all my texures on objects are gone (correct)but now the mixing works! i see a yellow AND blue “Image”, “Image2” result, both textures mixed, like i wanted, with one exception: all parts rendered with the texture bound to “Image2” inside the “Image”-creating FramBuffer draw pass now vanish.
cool, eh?
smoking on this for two days now.
sorry for no c-code and no use of cool gl debuggers, its coded in java.
any ideas?
(maybe “no fixed function with fragment shaders AND multitexture, please!!” or some strange limitations known?)
many thanks & greets
Paul