aboutsummaryrefslogtreecommitdiffstats
path: root/src/GLSLShaderTest/toon.frag
diff options
context:
space:
mode:
Diffstat (limited to 'src/GLSLShaderTest/toon.frag')
-rw-r--r--src/GLSLShaderTest/toon.frag34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/GLSLShaderTest/toon.frag b/src/GLSLShaderTest/toon.frag
new file mode 100644
index 0000000..fa50453
--- /dev/null
+++ b/src/GLSLShaderTest/toon.frag
@@ -0,0 +1,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);
+}