summaryrefslogtreecommitdiff
path: root/ground.frag
blob: 60d0c095b2d67ed3b2be235503a0ac37f34ebe8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#version 120

uniform vec3 light_eye;
varying vec4 shadow_coords;
varying vec3 vertex_eye;
uniform sampler2DShadow shadow_sampler;

void main()
{
	vec3 normal = vec3(0.0, 0.0, 1.0);
	vec4 material_color = vec4(1.0, 0.7, 0.5, 1.0);
	float shadow = shadow2DProj(shadow_sampler, shadow_coords).x;
	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)) * shadow, material_color.w);
}