Jump to content
  • Advertisement
Sign in to follow this  
Galapaegos

glsl shader errors

This topic is 4818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!