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
|
varying vec4 normal_es;
varying vec4 position_es;
const vec4 diffuse_color = vec4(1.0, 0.0, 0.0, 1.0);
/* Specular exponent.
*/
uniform float s;
/* Position of the light in eye-space.
*/
const vec4 light_es = vec4(0.0, 3.0, 0.0, 1.0);
void main(void)
{
vec3 l = normalize((light_es - position_es).xyz);
vec3 v = normalize(-position_es.xyz);
vec3 h = normalize(l + v);
float n_dot_l = dot(normal_es.xyz, l);
vec4 diff = diffuse_color * n_dot_l;
float spec = pow(dot(normal_es.xyz, h), s);
vec4 color = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragColor = step(0.0, n_dot_l) * vec4(diff.xyz + vec3(spec), 1.0);
}
|