vec3 normal = normalize(vec3(0.f, -1.f, 0.f)*in_normal);
vec3 light_colour = vec3(0.4f, 0.3f, 1.f);
vec3 light_position = vec3(0.f, -5.f, 2.f);
vec3 light_direction = normalize(light_position - in_position);
float diffuse_strength = max(dot(normal, light_direction), 0.f);
vec3 diffuse = diffuse_strength * light_colour;
float ambient_strength = 0.7;
vec3 ambient = ambient_strength * light_colour;
vec3 object_colour = vec3(1.f, 0.9f, 0.7f);
out_colour = vec4((ambient + diffuse)*object_colour, 1.0f);
Fragment shader for simple cell shading style.
Normal and position should be passed in from the vertex shader.