blob: fa50453bf4d1306cd03902643516ac6267e4cd71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
//
// Fragment shader for cartoon-style shading
//
// Author: Philip Rideout
//
// Copyright (c) 2004 3Dlabs Inc. Ltd.
//
// See 3Dlabs-License.txt for license information
//
//uniform vec3 DiffuseColor;
//uniform vec3 PhongColor;
//uniform float Edge;
//uniform float Phong;
vec3 DiffuseColor = vec3(0.5,0.5,1.0);
vec3 PhongColor = vec3(0.75,0.75,1.0);
float Edge = 0.64;
float Phong = 0.90;
varying vec3 Normal;
varying vec3 LightDir;
void main (void)
{
vec3 color = DiffuseColor;
float f = max( 0.0, dot(LightDir,Normal));
if (abs(f) < Edge)
color = DiffuseColor * 0.2;
if (f > Phong)
color = PhongColor;
gl_FragColor = vec4(color, 1);
}
|