Whenever I use a GLSL shader that uses one texture, the shader works perfectly. Simple test, three spheres one texture each:
http://vault101.co.uk/downloads/jogl_glsl_test_m1.png
Whenever I use a shader that uses more than two or more textures, the shader results in pure black output.
After using several more complex shaders with similar results I boiled this down to one very basic shader that still doesn’t work:
//VERT
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
// FRAG
uniform sampler2D tex;
uniform sampler2D abc;
void main()
{
vec4 color = texture2D(tex,gl_TexCoord[0].st) * texture2D(abc,gl_TexCoord[0].st);
gl_FragColor = color;
}
This is what this looks like in ShaderDesigner. Note I’ve cut up the screen a bit so you can see more dialog boxes:
http://vault101.co.uk/downloads/jogl_glsl_test_sd.png
and this is the result in my JOGL app:
http://vault101.co.uk/downloads/jogl_glsl_test_m2.png
This is how I’m sending the uniform variables:
gl.glClientActiveTexture(GL.GL_TEXTURE0);
gl.glBindTexture(GL.GL_TEXTURE_2D, OpenGL.textureLoader.getGLTextureArray()[texture[2]]);
gl.glClientActiveTexture(GL.GL_TEXTURE1);
gl.glBindTexture(GL.GL_TEXTURE_2D, OpenGL.textureLoader.getGLTextureArray()[texture[0]]);
glsl_test.enableShader(); // effectively a call to gl.glUseProgramObjectARB (shaderprogram);
gl.glUniform1iARB(gl.glGetUniformLocationARB(glsl_test.getProgram(), "tex"), 0);
gl.glUniform1iARB(gl.glGetUniformLocationARB(glsl_test.getProgram(), "abc"), 1);
gl.glPushMatrix();
gl.glTranslated(0, 1, 10);
glu.gluSphere(quadratic, 1.3f, 32, 32); // Draw A Sphere
gl.glPopMatrix();
glsl_test.disableShader(); // effectively a call to gl.glUseProgramObjectARB (0);
Any ideas why this would come out black? I’m using DebugGL on and the shader complie checks and link checks, which all report ok.
Thanks