Initializing uniforms in glsl

Hi, I created this simple vertex shader:

uniform vec3 xyz = vec3(0.0, 0.0, 0.0);
	void main() {
		vec3 normal, lightDir;
		vec4 diffuse;
		float NdotL;
		normal = normalize(gl_NormalMatrix * gl_Normal * xyz);
		lightDir = normalize(vec3(gl_LightSource[0].position));
		NdotL = max(dot(normal, lightDir), 0.0);
		diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;
		gl_FrontColor = NdotL * diffuse;
		gl_Position = ftransform();
	}

The only problem is that when I try compiling the shader object, it complains, giving a log message:

[quote]ERROR: 0:1: ‘uniform’ : cannot initialize this type of qualifier
[/quote]
However, in the glsl spec, they have examples where uniforms are initialized. Am I doing something wrong or could this be a bug in the drivers? My card is a Nvidia 8600MT in a macbook pro. I will check it on a desktop soon, just to test that theory.

Thanks

You are correct there are nearly identical initializations shown in the spec.

Nvidia uses their Cg (Nvidia’s shader language) compiler for GLSL as well, so something that might be worth looking at is whether or not Cg allows uniforms to be initialized like that. That will at least help narrow it down if it is a driver issue.

I glanced at the Cg spec and it seems they treat uniforms as function parameters that get their values from an external source. It was a little unclear, but I think they implied that uniforms couldn’t be initialized inside the shader.