summaryrefslogtreecommitdiffstats
path: root/dev/a6-harold/shaders/artsy.frag
blob: 403009dd1b7c8264455334ae12a3f1e5e0bd7d32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}