I’m trying to code a simple toon shader to visualize some models in a neat way. I borrowed the vertex/fragment shader off a friend, who has it working on his machine, but it would not compile on mine. The shader is so simple, and the error confuses me. Any help deciphering and fixing this error would be greatly appreciated! Maybe one of us has an outdated GLSL, but we’re both using the C# Tao wrapper for OpenGL so it seems unlikely… I’m not sure why it compiles and works on his machine and not on mine. (I have a separate Phong shader that compiles and works, so I doubt it’s my shader compiling/linking code)
EDIT: By the way, I wish GLSL would have an easy-to-find listing of all their error codes with descriptions. Then I could probably solve this (probably easy) problem by myself. :\ But I’m really new to GLSL, and I can’t devote an evening to this when I really should be working on things that aren’t extras, like a second shader.
Shader cannot compile, because:
FRAGMENT SHADER LOG:
(1) : warning C7011: implicit cast from “int” to “float”
(1) : error C1102: incompatible type for parameter #2 (“b”)
Vertex shader:
varying vec3 normal;
varying vec4 baseColor;
void main()
{
normal = gl_NormalMatrix * gl_Normal;
baseColor = gl_Color;
gl_Position = ftransform();
}
Fragment shader:
varying vec3 normal;
varying vec4 baseColor;
void main()
{
float intensity;
vec4 color;
vec3 n = normalize(normal);
intensity = dot(normalize(gl_LightSource[0].position), n);
if (intensity > 0.9975)
color = vec4(1, 1, 1, 1);
else if (intensity > 0.75)
color = baseColor;
else if (intensity > 0.5)
color = 0.75 * baseColor;
else if (intensity > 0.20)
color = 0.25 * baseColor;
else
color = 0.075 * baseColor;
gl_FragColor = color;
gl_FragColor.w = 1;
}