summaryrefslogtreecommitdiff
path: root/shaders/humus-celshading
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2011-09-08 23:02:27 -0700
committerEric Anholt <eric@anholt.net>2011-09-08 23:03:26 -0700
commitd46e939d8f28ed1c4162a33e99378d5797e4e3a1 (patch)
treef8b4f027e364551548ae84d2a45e4e232bf6d964 /shaders/humus-celshading
parent701c7392029e2364d3de14d31f22e99ae421e389 (diff)
Add some Humus demos I had around.
Diffstat (limited to 'shaders/humus-celshading')
-rw-r--r--shaders/humus-celshading/1.frag17
-rw-r--r--shaders/humus-celshading/1.vert18
-rw-r--r--shaders/humus-celshading/2.frag11
-rw-r--r--shaders/humus-celshading/2.vert23
-rw-r--r--shaders/humus-celshading/3.frag6
-rw-r--r--shaders/humus-celshading/3.vert6
6 files changed, 81 insertions, 0 deletions
diff --git a/shaders/humus-celshading/1.frag b/shaders/humus-celshading/1.frag
new file mode 100644
index 0000000..1b58efc
--- /dev/null
+++ b/shaders/humus-celshading/1.frag
@@ -0,0 +1,17 @@
+#define saturate(x) clamp(x,0.0,1.0)
+#define lerp mix
+#line 14
+
+
+uniform sampler1D CelShade;
+
+varying vec3 lVec;
+varying vec3 norm;
+
+void main(){
+ vec3 lightVec = normalize(lVec);
+ float diffuse = dot(lightVec, norm);
+
+ gl_FragColor = texture1D(CelShade, diffuse);
+}
+
diff --git a/shaders/humus-celshading/1.vert b/shaders/humus-celshading/1.vert
new file mode 100644
index 0000000..fb28d3b
--- /dev/null
+++ b/shaders/humus-celshading/1.vert
@@ -0,0 +1,18 @@
+#define saturate(x) clamp(x,0.0,1.0)
+#define lerp mix
+#line 0
+
+
+uniform vec3 lightPos;
+
+varying vec3 lVec;
+varying vec3 norm;
+
+void main(){
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ lVec = lightPos - gl_Vertex.xyz;
+ norm = gl_Normal;
+}
+
+
diff --git a/shaders/humus-celshading/2.frag b/shaders/humus-celshading/2.frag
new file mode 100644
index 0000000..97bf6df
--- /dev/null
+++ b/shaders/humus-celshading/2.frag
@@ -0,0 +1,11 @@
+#define saturate(x) clamp(x,0.0,1.0)
+#define lerp mix
+#line 19
+
+
+varying vec3 norm;
+
+void main(){
+ gl_FragColor = vec4(0.0);
+}
+
diff --git a/shaders/humus-celshading/2.vert b/shaders/humus-celshading/2.vert
new file mode 100644
index 0000000..63c2205
--- /dev/null
+++ b/shaders/humus-celshading/2.vert
@@ -0,0 +1,23 @@
+#define saturate(x) clamp(x,0.0,1.0)
+#define lerp mix
+#line 0
+
+
+uniform vec3 camPos;
+uniform float outlineThreshold;
+uniform float edgeThreshold;
+
+varying vec3 norm;
+
+void main(){
+ vec4 pos = gl_Vertex;
+ vec3 dir = camPos - gl_Vertex.xyz;
+
+ pos.w = float(
+ dot(dir, gl_MultiTexCoord0.xyz) * dot(dir, gl_MultiTexCoord1.xyz) < outlineThreshold ||
+ dot(gl_MultiTexCoord0.xyz, gl_MultiTexCoord1.xyz) < edgeThreshold);
+
+ gl_Position = gl_ModelViewProjectionMatrix * pos;
+}
+
+
diff --git a/shaders/humus-celshading/3.frag b/shaders/humus-celshading/3.frag
new file mode 100644
index 0000000..4c72c26
--- /dev/null
+++ b/shaders/humus-celshading/3.frag
@@ -0,0 +1,6 @@
+uniform vec4 color;
+void main()
+{
+ gl_FragColor = color;
+}
+
diff --git a/shaders/humus-celshading/3.vert b/shaders/humus-celshading/3.vert
new file mode 100644
index 0000000..b081d0f
--- /dev/null
+++ b/shaders/humus-celshading/3.vert
@@ -0,0 +1,6 @@
+attribute vec4 position;
+void main()
+{
+ gl_Position = position;
+}
+