View Full Version : Cel-Shader

06-15-2016, 08:38 AM
I try to write a cel-shader. But my model is white black and not red, how it should be. Can anyone see, what is wrong?

#version 130

// data from vertex shader
varying vec3 n[5];
varying vec3 l[5];
varying vec3 a[5];
varying vec3 world;
varying vec3 LightPosition[5];

//************************************************** *************
// parameters of the light and possible values
uniform vec3 LightAmbient[5];
uniform vec3 LightDiffuse[5];
uniform vec3 LightSpecular[5];

// parameters of the material and possible values
uniform vec3 MaterialAmbient, MaterialDiffuse, MaterialSpecular;
uniform float shininess;
uniform int NumberLights;

void main(void)
vec3 E = vec3(0.0, 0.0, 1.0);
vec3 H = normalize(LightPosition[0] + E);

float df= max(0.0, dot(n[0], l[0]));
float sf = max(0.0, dot(n[0], H));

sf = pow(sf, shininess);

vec3 color = MaterialAmbient + df * MaterialDiffuse + sf * MaterialSpecular;
gl_FragColor.xyz = color;