summaryrefslogtreecommitdiffstats
path: root/dev/a6-harold/shaders/artsy.frag
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2021-12-17 13:17:58 -0600
committerMatt Strapp <matt@mattstrapp.net>2021-12-17 13:17:58 -0600
commite0a8f6b97c473d28af96f28ca6b46d41b91646a3 (patch)
tree8faef1da18b809c9585c11ba5917f1f8268cddf6 /dev/a6-harold/shaders/artsy.frag
parentAdd README (diff)
parentClarify how to get eye point in Sky::ScreenPtHitsSky (diff)
downloadcsci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar
csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.gz
csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.bz2
csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.lz
csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.xz
csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.zst
csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.zip
Merge branch 'support-code' of https://github.umn.edu/umn-csci-4611-f21/shared-upstream
Diffstat (limited to '')
-rw-r--r--dev/a6-harold/shaders/artsy.frag29
1 files changed, 29 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;
+}