summaryrefslogtreecommitdiff
path: root/ground.frag
blob: 8af0fb535b48c94d28e2e685248d705f7fcfa623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
uniform vec3 light_eye;
varying vec3 shadow_coords;
varying vec3 vertex_eye;
uniform sampler2D shadow_sampler;

void main()
{
	vec3 normal = vec3(0.0, 0.0, 1.0);
	vec4 material_color = texture2DProj(shadow_sampler, shadow_coords);
	vec3 l = normalize(light_eye - vertex_eye);
	vec3 v = normalize(-vertex_eye);
	vec3 h = normalize(l + v);
	float n_dot_l = dot(normal, l);
	vec3 diffuse = material_color.xyz * n_dot_l;
	float specular = pow(dot(normal, h), 16.0);
	gl_FragColor = step(0.0, n_dot_l) *
	vec4(diffuse + vec3(specular), material_color.w);
}