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