glsl shader errors

Started by
3 comments, last by Galapaegos 18 years, 10 months ago
Hey guys, I'm getting some extremely strange behavior from my shader program. My goal was to write a caustic shader effect. I was able to design something close in ShaderDesigner to the effect that I wanted, and then I moved the code from the ShaderDesigner to my project. After correctin a couple silly mistakes (not setting a textue as a loc properly). Here is my vertex shader program:

void main ()
{
  gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;

Here is my fragment shader:

uniform sampler2D tex0;
uniform float period;
uniform float scale;
uniform float scale2;
uniform float scale3;

void main ()
{
  float x = gl_TexCoord[0].s;
  float z = gl_TexCoord[0].t;
  float pi = 3.14159*scale2;

  vec3 parx = vec3 (1 - scale*sin ((x + z)/period*pi), 0, z);
  vec3 parz = vec3 (x, 0, 1 - scale*sin ((x + z)/period*pi));
  vec3 prod = cross (parz, parx);
  vec3 grrr = normalize (prod);
  float ang = dot (grrr, vec3 (0, 1, 0));
  vec4 color = texture2D (tex0, tex);
  vec4 caust = scale3*ang*vec4 (1, 1, 1, 1);

  if (ang > 0.0)
    gl_FragColor = color + caust;
  else
    gl_FragColor = color;
}
I am receiving these error messages as a result of the two programs: vert: (10) : error C0000: syntax error, unexpected $undefined at token "<undefined>" (10) : error C0501: type name expected at token "<undefined>" frag: (26) : error C0000: syntax error, unexpected $undefined at token "<undefined>" (26) : error C0501: type name expected at token "<undefined>" The shaders compile properly in ShaderDesigner, which is why this is stumping me. Any suggestions? Thanks! -brad
-brad
Advertisement
Are you sending it the proper uniform data types?

Are period, scale, scale2, scale3 getting sent as floats?
Funkapotamus,

Yeah, I'm setting up those four as floats. However, its not making it past the compile stage, so it shouldn't have to worry about looking up those functions at that point in time, correct? Right after I link my shader programs, then I add my uniform variables (or should adding the variables be done before compiling/linking the programs?)

-brad
-brad
i've had a problem like this before, try zeroing the memory you load the shader into as that fixed it for me (alternatively, use my wonderfull shader loading classes)
_the_phantom_,

Thanks, that was the problem. It doesn't give me any weird messages like that anymore.

-brad
-brad

This topic is closed to new replies.

Advertisement