mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-24 03:21:19 +00:00
32 lines
803 B
GLSL
32 lines
803 B
GLSL
#version 400 core
|
|
uniform vec3 lDirection;
|
|
|
|
in vec3 fPosition;
|
|
in vec3 fNormal;
|
|
in vec4 ifColor;
|
|
|
|
out vec4 fColor;
|
|
|
|
void
|
|
main()
|
|
{
|
|
// Get lighting vectors
|
|
vec3 LightDirection = normalize(vec3(0, 1, 0)); // We assume light is at camera position
|
|
vec3 nfNormal = normalize(fNormal);
|
|
vec3 nviewDirection = normalize(fPosition);
|
|
|
|
// Compute diffuse component
|
|
float diffuse = max(0.0, dot(nfNormal, LightDirection));
|
|
|
|
// Compute specular component
|
|
vec3 Rl = normalize(-LightDirection+2.0*nfNormal*dot(nfNormal,LightDirection));
|
|
float specular = 0.1*pow(max(0.0, dot(Rl, nviewDirection)), 16);
|
|
|
|
// Fragment color (currently static, to be replaced with texture)
|
|
vec3 color = ifColor.xyz;
|
|
|
|
// Compute final color
|
|
fColor = vec4(color * (0.1 + diffuse + specular), 1);
|
|
// fColor = vec4(fNormal, 1);
|
|
}
|