12 uniform mat3 normalMatrix; 13 out vec3 normalEyeSpace; 16 normalEyeSpace = normalMatrix * inNormal; 17 gl_Position = MVP*vec4(inVert,1.0); 25 in vec3 normalEyeSpace; 27 uniform vec4 ambient;//=vec4(0.1,0.1,0.1,1.0); 28 uniform vec4 Colour;//=vec4(1.0,1.0,1.0,1.0); 29 uniform vec4 specular;//=vec4(1.0,1.0,1.0,1.0); 30 uniform float shininess;//=20; 31 uniform vec3 lightPos;//=vec3(1,1,1); 34 float stepmix(float edge0, float edge1, float E, float x) 36 float T = clamp(0.5 * (x - edge0 + E) / E, 0.0, 1.0); 37 return mix(edge0, edge1, T); 42 vec3 N = normalize(normalEyeSpace); 43 vec3 L = normalize(lightPos); 44 vec3 Eye = vec3(0, 0, 1); 45 vec3 H = normalize(L + Eye); 46 float df = max(0.0, dot(N, L)); 47 float sf = max(0.0, dot(N, H)); 48 sf = pow(sf, shininess); 54 if (df > A - E && df < A + E) df = stepmix(A, B, E, df); 55 else if (df > B - E && df < B + E) df = stepmix(B, C, E, df); 56 else if (df > C - E && df < C + E) df = stepmix(C, D, E, df); 57 else if (df < A) df = 0.0; 58 else if (df < B) df = B; 59 else if (df < C) df = C; 62 if (sf > 0.5 - E && sf < 0.5 + E) 64 sf = smoothstep(0.5 - E, 0.5 + E, sf); 70 FragColor = ambient + df * Colour + sf * specular; const std::string toonVertexShader
const std::string toonFragmentShader
GLsizei const GLchar *const * string