terrain working - no culling
[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 vec2 tex_coord;
13
14 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         vec4 texel = texture2D(tex, tex_coord);
29         color.xyz = diffuse.xyz * cdiff * texel.xyz + specular.xyz * cspec;
30         color.w = 1.0;
31 }