PDA

View Full Version : About GLSL shader compile error



Cgor_Cyrosly
07-15-2007, 04:33 AM
I used cgc 2.0 to compile glsl vertex shader,and return the down information:
multiTex.glslv(25) : error C7506: OpenGL does not define the global function dot
multiTex.glslv(25) : error C7506: OpenGL does not define the global function max

I dont know why the error occured.
help!!!
My code as down:



#version 120
varying vec3 normal;
varying vec3 V;
uniform vec4 ambientDiffuse;
uniform vec4 lightDiffuse;

void main()
{
vec4 texCoord[]={gl_MultiTexCoord0,gl_MultiTexCoord1,
gl_MultiTexCoord2,gl_MultiTexCoord3,
gl_MultiTexCoord4,gl_MultiTexCoord5,
gl_MultiTexCoord6,gl_MultiTexCoord7};

gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex ;

for(int i=0;i<gl_MaxTextureCoords;i++)
{
gl_TexCoord[i]=texCoord[i];
}

normal=normalize(gl_NormalMatrix*gl_Normal);

V=normalize((gl_ModelViewMatrix*gl_Vertex-gl_LightSource[0].position).xyz);

gl_FrontColor=max(dot(normal,V),0.0)*ambientDiffus e*lightDiffuse;
}and I set the *.bat file like this:

cgc -profile glslv -entry main -oglsl -o asm.txt -l cInfo.txt multiTex.glslv

ZbuffeR
07-15-2007, 09:55 AM
cgc is a Cg tool.
According to this :
http://lists.apple.com/archives/Mac-opengl/2007/Feb/msg00068.html
it is not very robust.

You may try GLSL Validate :
http://developer.3dlabs.com/downloads/glslvalidate/index.htm

Cgor_Cyrosly
07-15-2007, 09:51 PM
Thanks ,but cgc 2.0 supported leave context(background) compiler for GLSL.I used it compile many GLSL shader and all passed through before I reinstalled system.

zed
07-15-2007, 11:18 PM
are u parsing it correctly?

also nvidia cards (not sure about the nv80)
only allow 32varying floats

gl_TexCoord[i]=texCoord[i]; equals 4 floats
(4*8 texture units = 32 + then add the normal + V + youll run into the message max varyings exceeded)

Cgor_Cyrosly
07-16-2007, 04:58 AM
Varying floats?Not problem with it.See the compiler error:

multiTex.glslv(25) : error C7506: OpenGL does not define the global function dot
multiTex.glslv(25) : error C7506: OpenGL does not define the global function max

Relic
07-16-2007, 05:10 AM
cgc -profile glslv -entry main -oglsl -o asm.txt -l cInfo.txt multiTex.glslv
Why are you compiling a GLSL source to a GLSL profile?
I would have expected arbvp1, vp30, or vp40 as profile.

And you should really not use your texCoord array this way.
It would break if gl_MaxTexCoords > 8 because you hardcoded eight MultiTexCoord into the array. Just assign them manually, that's the simplest way to get it right.
And when compiling this to an assembly profile you will see that you will run out of varyings with eight gl_TexCoords plus two vec3 varyings.

Brolingstanz
07-16-2007, 10:31 AM
"also nvidia cards (not sure about the nv80)
only allow 32varying floats"

G80 reports a whopping 60.

Cgor_Cyrosly
07-16-2007, 06:15 PM
It not passed through also after I changed the number of gl_MultiTexCoord form 8 to 4 and return the same error that:the function "dot" and "max" not defined in GL