6 flat out vec4 color; // Shaded color
9 uniform mat4 perspview;
13 mat4 m = perspview * model;
14 vec3 dark = col * 0.1;
15 vec3 u_light = vec3( 0.5, -0.7, -0.6);
16 vec3 v_normal = transpose(inverse(mat3(model))) * normal;
18 float distance = model[3][2];
19 float attenuation = 1. / (1. + distance * distance * 0.05);
20 float brightness = max(dot(normalize(v_normal), normalize(u_light)) * attenuation, 0.0);
21 color = vec4(mix(dark, col, brightness), 1.0);
23 gl_Position = m * vec4(position, 1.0);