View Full Version : Calling a glsl function

12-05-2004, 09:03 AM
I have a vertex shader that computes some lighting effects. When I try to call the following function:

void DirectionalLight(in int i,in vec3 normal, inout vec4 diffuse)
float nDotVP;
float nDotHV;

nDotVP = max(0.0, dot(normal, vec3(gl_LightSource[i].position)));
nDotHV = max(0.0, dot(normal, vec3(gl_LightSource[i].halfVector)));
diffuse += gl_LightSource[i].diffuse * nDotVP;

I get this error:
"The glsl vertex shader will run in software - availble number of temporary registers exceeded..."

If I comment out the line:
nDotHV = max(0.0, dot(normal, vec3(gl_LightSource[i].halfVector)));

Then the shader runs in hardware.

Also, if I "manually inline" the function in main(), then the shader also runs in hardware.

What exactly does the error "availble number of temporary registers exceeded" mean?

Thanks for any insight

12-05-2004, 09:30 AM
I was getting this when I was doing GLSL on ATI.
ATI R300 has relatively lots of temporary registers (32), but the compiler has some issues and ends up wasting all the registers.

Inlining is one solution. The other is to not index the lights with a variable.
Use immediate values.

Search the shader forum on this topic.