7 uniform float shininess;
12 varying vec2 tex_coord;
14 // const float fog_density = 0.005;
15 uniform float fog_density;
16 const vec4 sky_color = vec4(0.35, 0.5, 0.65, 1.0);
22 vec3 p = normalize(pos); // view space dir
23 vec3 n = normalize(normal);
24 vec3 l = normalize(ldir);
26 vec3 r = normalize(-reflect(l, n));
27 vec3 vdir = normalize(-p);
29 float cdiff = max(dot(l, n), 0.0);
30 float cspec = pow(max(dot(r, vdir), 0.0), shininess);
33 float fog = clamp(exp(-fog_density * dist), 0.0, 1.0);
35 vec4 texel = texture2D(tex, tex_coord);
38 object_color.xyz = diffuse.xyz * cdiff * texel.xyz + specular.xyz * cspec;
41 color = mix(sky_color, object_color, fog);