PDA

View Full Version : Uniform in GLSL



vince
05-18-2004, 08:43 AM
I have a problem in GLSL. My uniform never seem to make it through to vertex or fragment shader.

Here is my fragment Shader:
uniform int nTexEnvMode0;
uniform sampler2D nTextIdx[8];
void main(void)
{
vec4 texval;
gl_FragColor = gl_Color;
if (nTexEnvMode0 == 1)
{
texval = texture2D(nTextIdx[nTex], vec2(gl_TexCoord[nTex]));
gl_FragColor *= texval;
}
};

As you can see, this is a very basic shader trying to apply a texture if my uniform is set.

I set it the following way:

int nTexEnvMode0Location = glGetUniformLocationARB( nProgramObject, "nTexEnvMode0");
glUniform1iARB( nTexEnvMode0Location, 1 );

To me this should set the label nTexEnvMode0 to a permanent value of 1 since I don't change it afterward. But it doesn't work. It remains untexture, but the behaviour is fine if I force nTexEnvMode0 to 1 inside my shader, which prooves the problem is with the uniform.

Am I doing anything wrong?

BTW I'm using a GeForce 5900 Ultra with the latest driver.

Thanks

vince
05-21-2004, 09:53 AM
Hum, no answer... I didn't think it was a though one...

The easy version of the question would be: Am I the only not being able to control uniforms?

Vincent

Aeluned
05-21-2004, 11:43 AM
where is this 'nTex' coming from that you are using as an index to gl_TexCoord[] and into your nTextureIdx[] array?

jeremyz
05-21-2004, 12:29 PM
Could you post a test app? Or would that be impractical?