5
const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
6
const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
7
const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
8
const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
9
const vec4 MaterialDiffuse = vec4(0.0, 0.0, 1.0, 1.0);
10
const vec4 MaterialSpecular = vec4(1.0, 1.0, 1.0, 1.0);
11
const float MaterialShininess = 100.0;
13
vec3 N = normalize(Normal);
15
// In the lighting model we are using here (Blinn-Phong with light at
16
// infinity, viewer at infinity), the light position/direction and the
17
// half vector is constant for the all the fragments.
18
vec3 L = normalize(LightSourcePosition.xyz);
19
vec3 H = normalize(LightSourceHalfVector);
21
// Calculate the diffuse color according to Lambertian reflectance
22
vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
24
// Calculate the ambient color
25
vec4 ambient = MaterialAmbient * LightSourceAmbient;
27
// Calculate the specular color according to the Blinn-Phong model
28
vec4 specular = MaterialSpecular * LightSourceSpecular *
29
pow(max(dot(N,H), 0.0), MaterialShininess);
31
// Calculate the final color
32
gl_FragColor = ambient + specular + diffuse;
5
const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0);
6
const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0);
7
const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0);
8
const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0);
9
const vec4 MaterialDiffuse = vec4(0.0, 0.0, 1.0, 1.0);
10
const vec4 MaterialSpecular = vec4(1.0, 1.0, 1.0, 1.0);
11
const float MaterialShininess = 100.0;
13
vec3 N = normalize(Normal);
15
// In the lighting model we are using here (Blinn-Phong with light at
16
// infinity, viewer at infinity), the light position/direction and the
17
// half vector is constant for the all the fragments.
18
vec3 L = normalize(LightSourcePosition.xyz);
19
vec3 H = normalize(LightSourceHalfVector);
21
// Calculate the diffuse color according to Lambertian reflectance
22
vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0);
24
// Calculate the ambient color
25
vec4 ambient = MaterialAmbient * LightSourceAmbient;
27
// Calculate the specular color according to the Blinn-Phong model
28
vec4 specular = MaterialSpecular * LightSourceSpecular *
29
pow(max(dot(N,H), 0.0), MaterialShininess);
31
// Calculate the final color
32
gl_FragColor = vec4((ambient + specular + diffuse).xyz, 1.0);