summaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-03-22 17:29:32 -0700
committerEric Anholt <eric@anholt.net>2013-03-22 17:31:41 -0700
commit3db77a1625bab9ceda10f5fa66e38bbc0e42393f (patch)
tree23bd55d718964b77d1ecde5bf5f096a1f4ba722c /shaders
parent8f179dc508736ed25b16e84d2528c225d0ba865c (diff)
anholt: Switch the shaders from my demo to shader_test files.
Diffstat (limited to 'shaders')
-rw-r--r--shaders/anholt/12.shader_test23
-rw-r--r--shaders/anholt/15.shader_test17
-rw-r--r--shaders/anholt/18.shader_test24
-rw-r--r--shaders/anholt/3.shader_test (renamed from shaders/anholt/glass.frag)38
-rw-r--r--shaders/anholt/6.shader_test59
-rw-r--r--shaders/anholt/9.shader_test16
-rw-r--r--shaders/anholt/ground.frag21
-rw-r--r--shaders/anholt/shadow.frag3
-rw-r--r--shaders/anholt/shadowmap_display.frag7
9 files changed, 177 insertions, 31 deletions
diff --git a/shaders/anholt/12.shader_test b/shaders/anholt/12.shader_test
new file mode 100644
index 0000000..73d9ec8
--- /dev/null
+++ b/shaders/anholt/12.shader_test
@@ -0,0 +1,23 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+uniform sampler2D shadow_sampler;
+varying vec2 texcoord;
+
+void main()
+{
+ gl_FragColor = texture2D(shadow_sampler, texcoord);
+}
+
+[vertex shader]
+#version 120
+
+varying vec2 texcoord;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+ texcoord = (gl_Vertex.xy + vec2(1, 1)) / 2.0;
+}
+
diff --git a/shaders/anholt/15.shader_test b/shaders/anholt/15.shader_test
new file mode 100644
index 0000000..30ba541
--- /dev/null
+++ b/shaders/anholt/15.shader_test
@@ -0,0 +1,17 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+uniform vec4 color;
+void main()
+{
+ gl_FragColor = color;
+}
+
+[vertex shader]
+attribute vec4 position;
+void main()
+{
+ gl_Position = position;
+}
+
diff --git a/shaders/anholt/18.shader_test b/shaders/anholt/18.shader_test
new file mode 100644
index 0000000..e59381e
--- /dev/null
+++ b/shaders/anholt/18.shader_test
@@ -0,0 +1,24 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#version 130
+uniform ivec4 color;
+out ivec4 out_color;
+
+void main()
+{
+ out_color = color;
+}
+
+[vertex shader]
+#version 130
+in vec4 position;
+void main()
+{
+ gl_Position = position;
+}
+
+event = 0x0001
+event = 0x0001
+300 frames in 5.40 secs: 55.6 fps
diff --git a/shaders/anholt/glass.frag b/shaders/anholt/3.shader_test
index 88c29b8..0a0c5a1 100644
--- a/shaders/anholt/glass.frag
+++ b/shaders/anholt/3.shader_test
@@ -1,3 +1,7 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
#version 120
#define I965_HACK 1
@@ -111,3 +115,37 @@ void main()
gl_FragColor = texture2D(normal_sampler, texcoord);
#endif
}
+
+[vertex shader]
+#version 120
+
+uniform vec3 light_eye;
+varying vec2 texcoord;
+varying vec3 light_surf;
+varying vec3 eye_surf;
+varying vec3 tangent_surf;
+varying vec4 shadow_coords;
+uniform mat4 mvp, mv, light_mvp;
+
+void main()
+{
+ mat3 mv3 = mat3(mv);
+ vec3 t = (mv3 * gl_MultiTexCoord1.xyz);
+ vec3 n = (mv3 * gl_Normal);
+
+ gl_Position = mvp * gl_Vertex;
+
+ mat3 tbn = mat3(t,
+ cross(n, t),
+ n
+ );
+
+ vec3 vertex_eye = vec3(mv * gl_Vertex);
+ shadow_coords = light_mvp * gl_Vertex;
+
+ texcoord = gl_MultiTexCoord0.xy;
+ light_surf = normalize((light_eye - vertex_eye) * tbn);
+ eye_surf = normalize((-vertex_eye) * tbn);
+ tangent_surf = gl_MultiTexCoord1.xyz * tbn;
+}
+
diff --git a/shaders/anholt/6.shader_test b/shaders/anholt/6.shader_test
new file mode 100644
index 0000000..9e7084b
--- /dev/null
+++ b/shaders/anholt/6.shader_test
@@ -0,0 +1,59 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#version 120
+
+uniform vec3 light_eye;
+varying vec4 shadow_coords;
+varying vec3 vertex_eye;
+uniform sampler2DShadow shadow_sampler;
+
+void main()
+{
+ vec3 normal = vec3(0.0, 0.0, 1.0);
+ vec4 material_color = vec4(1.0, 0.7, 0.5, 1.0);
+ float shadow = shadow2DProj(shadow_sampler, shadow_coords).x;
+ vec3 l = normalize(light_eye - vertex_eye);
+ vec3 v = normalize(-vertex_eye);
+ vec3 h = normalize(l + v);
+ float n_dot_l = dot(normal, l);
+ vec3 diffuse = material_color.xyz * n_dot_l;
+ float specular = pow(dot(normal, h), 16.0);
+ gl_FragColor = step(0.0, n_dot_l) *
+ vec4((diffuse + vec3(specular)) * shadow, material_color.w);
+}
+
+[vertex shader]
+/*uniform vec3 light_eye;
+varying vec2 texcoord;
+varying vec3 light_surf;
+varying vec3 eye_surf;
+varying vec3 tangent_surf;
+*/
+varying vec3 vertex_eye;
+varying vec4 shadow_coords;
+uniform mat4 mvp, mv, light_mvp;
+
+void main()
+{
+/* vec3 t = (mv * vec4(1.0,, 0.0)).xyz;
+ vec3 n = (mv * vec4(gl_Normal, 0.0)).xyz;
+*/
+ gl_Position = mvp * gl_Vertex;
+ vertex_eye = vec3(mv * gl_Vertex);
+ shadow_coords = light_mvp * gl_Vertex;
+/*
+ mat3 tbn = mat3(t,
+ cross(n, t),
+ n
+ );
+
+
+ texcoord = vec2(gl_MultiTexCoord0.x * 4, gl_MultiTexCoord0.y);
+ light_surf = normalize((light_eye - vertex_eye) * tbn);
+ eye_surf = normalize((-vertex_eye) * tbn);
+ tangent_surf = gl_MultiTexCoord1.xyz * tbn;
+*/
+}
+
diff --git a/shaders/anholt/9.shader_test b/shaders/anholt/9.shader_test
new file mode 100644
index 0000000..63eb250
--- /dev/null
+++ b/shaders/anholt/9.shader_test
@@ -0,0 +1,16 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+void main()
+{
+}
+
+[vertex shader]
+uniform mat4 mvp, mv;
+
+void main()
+{
+ gl_Position = mvp * gl_Vertex;
+}
+
diff --git a/shaders/anholt/ground.frag b/shaders/anholt/ground.frag
deleted file mode 100644
index 60d0c09..0000000
--- a/shaders/anholt/ground.frag
+++ /dev/null
@@ -1,21 +0,0 @@
-#version 120
-
-uniform vec3 light_eye;
-varying vec4 shadow_coords;
-varying vec3 vertex_eye;
-uniform sampler2DShadow shadow_sampler;
-
-void main()
-{
- vec3 normal = vec3(0.0, 0.0, 1.0);
- vec4 material_color = vec4(1.0, 0.7, 0.5, 1.0);
- float shadow = shadow2DProj(shadow_sampler, shadow_coords).x;
- vec3 l = normalize(light_eye - vertex_eye);
- vec3 v = normalize(-vertex_eye);
- vec3 h = normalize(l + v);
- float n_dot_l = dot(normal, l);
- vec3 diffuse = material_color.xyz * n_dot_l;
- float specular = pow(dot(normal, h), 16.0);
- gl_FragColor = step(0.0, n_dot_l) *
- vec4((diffuse + vec3(specular)) * shadow, material_color.w);
-}
diff --git a/shaders/anholt/shadow.frag b/shaders/anholt/shadow.frag
deleted file mode 100644
index 9198103..0000000
--- a/shaders/anholt/shadow.frag
+++ /dev/null
@@ -1,3 +0,0 @@
-void main()
-{
-}
diff --git a/shaders/anholt/shadowmap_display.frag b/shaders/anholt/shadowmap_display.frag
deleted file mode 100644
index 8db3446..0000000
--- a/shaders/anholt/shadowmap_display.frag
+++ /dev/null
@@ -1,7 +0,0 @@
-uniform sampler2D shadow_sampler;
-varying vec2 texcoord;
-
-void main()
-{
- gl_FragColor = texture2D(shadow_sampler, texcoord);
-}