summaryrefslogtreecommitdiffstats
path: root/dev/a6-harold/shaders
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dev/a6-harold/shaders/artsy.frag29
-rw-r--r--dev/a6-harold/shaders/artsy.vert17
-rw-r--r--dev/a6-harold/shaders/outline.frag7
-rw-r--r--dev/a6-harold/shaders/outline.vert23
-rw-r--r--dev/a6-harold/shaders/stroke2d.frag9
-rw-r--r--dev/a6-harold/shaders/stroke2d.vert7
-rw-r--r--dev/a6-harold/shaders/stroke3d.frag9
-rw-r--r--dev/a6-harold/shaders/stroke3d.vert10
8 files changed, 111 insertions, 0 deletions
diff --git a/dev/a6-harold/shaders/artsy.frag b/dev/a6-harold/shaders/artsy.frag
new file mode 100644
index 0000000..403009d
--- /dev/null
+++ b/dev/a6-harold/shaders/artsy.frag
@@ -0,0 +1,29 @@
+#version 330
+
+in vec3 Position;
+in vec3 Normal;
+
+out vec4 color;
+
+uniform vec3 lightPosition;
+uniform vec4 Ia, Id, Is;
+
+uniform vec4 ka, kd, ks;
+uniform float s;
+
+uniform sampler2D diffuseRamp;
+uniform sampler2D specularRamp;
+
+
+void main() {
+ vec3 l = normalize(lightPosition.xyz - Position);
+ vec3 n = normalize(Normal);
+ vec3 e = normalize(-Position);
+ vec3 h = normalize(e + l);
+ float diffuse = (dot(l,n) + 1)/2;
+ float specular = pow(max(dot(n,h),0), s);
+ color = ka*Ia
+ + kd*Id*texture(diffuseRamp, vec2(diffuse,0))
+ + ks*Is*texture(specularRamp, vec2(specular,0));
+ color.a = 1;
+}
diff --git a/dev/a6-harold/shaders/artsy.vert b/dev/a6-harold/shaders/artsy.vert
new file mode 100644
index 0000000..cd9b998
--- /dev/null
+++ b/dev/a6-harold/shaders/artsy.vert
@@ -0,0 +1,17 @@
+#version 330
+
+uniform mat4 modelViewMatrix;
+uniform mat4 normalMatrix;
+uniform mat4 projectionMatrix;
+
+layout(location = 0) in vec3 vertex;
+layout(location = 1) in vec3 normal;
+
+out vec3 Position;
+out vec3 Normal;
+
+void main() {
+ Position = (modelViewMatrix * vec4(vertex,1)).xyz;
+ Normal = normalize((normalMatrix * vec4(normal,0)).xyz);
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(vertex,1);
+}
diff --git a/dev/a6-harold/shaders/outline.frag b/dev/a6-harold/shaders/outline.frag
new file mode 100644
index 0000000..096721d
--- /dev/null
+++ b/dev/a6-harold/shaders/outline.frag
@@ -0,0 +1,7 @@
+#version 330
+
+out vec4 color;
+
+void main() {
+ color = vec4(0,0,0, 1);
+}
diff --git a/dev/a6-harold/shaders/outline.vert b/dev/a6-harold/shaders/outline.vert
new file mode 100644
index 0000000..a6073e5
--- /dev/null
+++ b/dev/a6-harold/shaders/outline.vert
@@ -0,0 +1,23 @@
+#version 330
+
+uniform mat4 modelViewMatrix;
+uniform mat4 normalMatrix;
+uniform mat4 projectionMatrix;
+uniform float thickness;
+
+layout(location = 0) in vec3 vertex;
+layout(location = 1) in vec3 normal;
+layout(location = 2) in vec3 leftNormal;
+layout(location = 3) in vec3 rightNormal;
+
+void main() {
+ vec3 p = (modelViewMatrix * vec4(vertex,1)).xyz;
+ vec3 e = -p;
+ vec3 nl = (normalMatrix * vec4(leftNormal,0)).xyz;
+ vec3 nr = (normalMatrix * vec4(rightNormal,0)).xyz;
+ vec3 v = vertex;
+ if (dot(e,nl) * dot(e,nr) < 0.0) {
+ v += thickness*normal;
+ }
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(v,1);
+}
diff --git a/dev/a6-harold/shaders/stroke2d.frag b/dev/a6-harold/shaders/stroke2d.frag
new file mode 100644
index 0000000..2dd7efa
--- /dev/null
+++ b/dev/a6-harold/shaders/stroke2d.frag
@@ -0,0 +1,9 @@
+#version 330
+
+uniform vec4 strokeColor;
+
+out vec4 color;
+
+void main() {
+ color = strokeColor;
+}
diff --git a/dev/a6-harold/shaders/stroke2d.vert b/dev/a6-harold/shaders/stroke2d.vert
new file mode 100644
index 0000000..e40fdec
--- /dev/null
+++ b/dev/a6-harold/shaders/stroke2d.vert
@@ -0,0 +1,7 @@
+#version 330
+
+layout(location = 0) in vec3 vertex;
+
+void main() {
+ gl_Position = vec4(vertex,1);
+}
diff --git a/dev/a6-harold/shaders/stroke3d.frag b/dev/a6-harold/shaders/stroke3d.frag
new file mode 100644
index 0000000..2dd7efa
--- /dev/null
+++ b/dev/a6-harold/shaders/stroke3d.frag
@@ -0,0 +1,9 @@
+#version 330
+
+uniform vec4 strokeColor;
+
+out vec4 color;
+
+void main() {
+ color = strokeColor;
+}
diff --git a/dev/a6-harold/shaders/stroke3d.vert b/dev/a6-harold/shaders/stroke3d.vert
new file mode 100644
index 0000000..d333c4f
--- /dev/null
+++ b/dev/a6-harold/shaders/stroke3d.vert
@@ -0,0 +1,10 @@
+#version 330
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+
+layout(location = 0) in vec3 vertex;
+
+void main() {
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(vertex,1);
+}