Cant get glsl to work

Hey guys,

I’m using Panda3D with python and trying to use GLSL on panda but I keep getting this error:
:display:gsg:glgsg(error): An error occurred while compiling shader!
ERROR: 0:27: ‘gl_FragColor’ : undeclared identifier

I’ve looked up on the forums and found a post talking about a bug in 1.7.0 so I downloaded this build panda3d.org/buildbot/builds/ … 24-272.dmg and installed it, still no results. Here are the shader codes:

Vertex:

varying vec3 normal;
varying vec4 ec_pos;

void main(){

    normal = gl_NormalMatrix * gl_Normal;
    ec_pos = gl_Vertex * gl_ModelViewMatrix;
    gl_Position = ftransform();

}

Fragment:

varying vec3 normal;
varying vec4 ec_pos;
void main(){

    vec4 color = vec4(0.3, 0.7, 1.0, 1.0);
    vec3 light = vec3( gl_LightSource[0].position );
    vec3 lightdir = light - ec_pos.xyz;
    vec3 reflectVec = normalize(reflect( -lightdir, normal ));
    vec3 viewVec = normalize( -ec_pos.xyz );
    float diff = max( dot(normalize(lightdir), normalize(normal)), 0.0);
    float spec = 0.0;
    if (diff > 0.0){
        spec = max(dot(reflectVec, viewVec), 0.0);
    }
    diff =  diff * 0.6 + spec * 0.4;
    if (diff > 0.90)
        diff = 1.1;
    else if (diff > 0.5)
        diff = 0.7;
    else
        diff = 0.5;
    //gl_FragColor =  diff * color;
    gl_FragColor =  diff;

}

I already compiled and tested those shaders in MacOS X OpenGL Shader Builder - worked perfectly.

Works fine for me, though it does complain about the assignment of the float “diff” to the vec4 “glFragColor”. But when I use the commented-out assignment, it works.

Are you sure you are loading the shader correctly? Are you sure you are specifying the vertex shader and the fragment shader in the correct positions?

David

Yeah, I was passing them in the wrong order. Cant believe I didn’t see it.