388ba76a607608108f07ad2a31ebf4b6f5d74345
[demo] / gl_shaders / default.f.glsl
1 #version 450
2
3 uniform sampler2D tex;
4
5 uniform vec4 diffuse;
6 uniform vec4 specular;
7 uniform float shininess;
8
9 varying vec3 pos;
10 varying vec3 normal;
11 varying vec3 ldir;
12 varying vec3 tex_coord;
13
14 layout(location = 0) out vec4 color;
15
16 void main()
17 {
18         vec3 p = normalize(pos);
19         vec3 n = normalize(normal);
20         vec3 l = normalize(ldir);
21
22         vec3 r = normalize(-reflect(l, n));
23         vec3 vdir = normalize(-p);
24
25         float cdiff = max(dot(l, n), 0.0);
26         float cspec = pow(max(dot(r, vdir), 0.0), shininess);
27
28         color = diffuse * cdiff * texture2D(tex, tex_coord.xy) + specular * cspec;
29 }