#version 330 layout(location = 0) in vec3 in_position; layout(location = 1) in vec2 in_texCoord; layout(location = 2) in vec3 in_normal; out vec2 out_texCoord; out vec4 out_color; uniform mat4 perspectiveMatrix; uniform mat4 viewMatrix; uniform mat4 worldMatrix; uniform vec3 viewPosition; uniform vec3 globalAmbient; uniform vec3 lightPosition; uniform vec3 lightColor; uniform vec3 emission; uniform vec3 ambient; uniform vec3 diffuse; uniform vec3 specular; uniform float shininess; void main() { mat3 worldMatrix3 = mat3(worldMatrix); vec3 position = worldMatrix3 * in_position; vec3 surfaceNormal = normalize(transpose(inverse(worldMatrix3)) * in_normal); vec3 a = ambient * globalAmbient; vec3 d = diffuse * lightColor; vec3 s = specular * lightColor; vec3 lightDirection = normalize(lightPosition - position); float cosIncidence = clamp(dot(surfaceNormal, lightDirection), 0.0f, 1.0f); d *= cosIncidence; if (cosIncidence > 0.0f) { vec3 viewDirection = normalize(viewPosition - position); vec3 halfDirection = normalize(lightDirection + viewDirection); float phongTherm = clamp(dot(surfaceNormal, halfDirection), 0.0f, 1.0f); phongTherm = pow(phongTherm, shininess); s *= phongTherm; } gl_Position = (perspectiveMatrix * viewMatrix * worldMatrix) * vec4(in_position, 1.0f); out_texCoord = in_texCoord; out_color = vec4(emission + a + d + s, 1.0f); }

#version 330 in vec2 out_texCoord; in vec4 out_color; out vec4 ex_color; void main() { ex_color = out_color; }

**Edited by irlanrobson, 17 February 2014 - 11:33 AM.**