Uniforms not working for one shader only ?!

Hi,

I’m using 3 shader programs and it turns out that my calls to glUniform are not working but only for the first one : I get the default values in the shader (0.0 for the floats).
The program is linked, the uniforms have their locations…
I don’t understand.
Thanks for your help !
B

Without code we can only guess :slight_smile: .

Ok, nothing extraordinary going on :


////////////////////
// C++ code:
////////////////////
// use the program
glUseProgram();
// Send the uniforms
glUniform1f(loc, val);
// and draw
glDraw();

////////////////////
// Vertex shader
////////////////////
uniform mat4 matModelView;
uniform mat4 matProjection;
uniform float aabbLength;
uniform float lod1;
uniform float lod2;

in vec4 vPosition;

flat out int isVisiblei;
flat out ivec2 info;

void main(void)
{
    isVisiblei = 1;

    info = ivec2(gl_VertexID, 0);

    // Transform and project !
    vec4 translatedposition4f = matProjection * (matModelView * vPosition);

    // Frustum-cull
    if(translatedposition4f.x+aabbLength < -translatedposition4f.w)
        {isVisiblei=0;return;}
    if(translatedposition4f.x-aabbLength >  translatedposition4f.w)
        {isVisiblei=0;return;}
    if(translatedposition4f.y+aabbLength < -translatedposition4f.w)
        {isVisiblei=0;return;}
    if(translatedposition4f.y-aabbLength >  translatedposition4f.w)
        {isVisiblei=0;return;}
    if(translatedposition4f.z+aabbLength < -translatedposition4f.w)
        {isVisiblei=0;return;}
    if(translatedposition4f.z-aabbLength >  translatedposition4f.w)
        {isVisiblei=0;return;}

    // compute lod
    if(translatedposition4f.z > lod2)
        {info.y = 2; return;}
    if(translatedposition4f.z > lod1)
        {info.y = 1; return;}
}

If I test the value of say the aabbLength variable, I get the default value 0.0… And I know the matrices are wrong also since the culling fails and I know this code works (used it before). Any ideas ?

You have no version specification in your vertex shader. The default is “#version 110” (GLSL 1.1). Several things you have in your shader require “#version 130” (GLSL 1.3), such as “flat” and “gl_VertexID”.

Chances are your shader isn’t even compiling. Are you checking for compilation errors?

If it is compiling, what OpenGL implementation are you using anyway? (vendor/version)

No it’s compiling and I am specifying the version (150) aswell, just didn’t put it in the code.
I am using GL context 2.1 with glew with an ati hd5770 and xubuntu 10.04. If I change the context to 3.2 it still doesn’t work though. What’s really strange is that the other two shader programs run fine and I use them in the same function.

Ok it was a driver issue, I downgraded back to my old version and everything’s working again.

I experienced a similar issue: in some circumstances the shader program ignored uniforms values (all of them) passed by glUniform*.

My program used gl_VertexID as well, so this might be the case. However, I have other programs that use gl_VertexID and uniforms without a problem.

My driver is Catalyst-10.3-opengl4-preview.
It’s definitely an ATI issue, but I’m not able to produce a good test case to help ATI to fix it…

Ok it was a driver issue

How did you determine this?

Yes I had updated to the gl4 preview version aswell

Well I can only guess really but my old programs didn’t work anymore since the installation neither ! So changed and everything is running smooth again… (I’m back to catalyst 10.1).