From 3e757dbc71682972899a48651710c5d8280c3cee Mon Sep 17 00:00:00 2001 From: Kiet Tran Date: Mon, 29 Nov 2021 13:36:54 -0600 Subject: Publish A6 --- dev/a6-harold/shaders/artsy.frag | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 dev/a6-harold/shaders/artsy.frag (limited to 'dev/a6-harold/shaders/artsy.frag') 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; +} -- cgit v1.2.3