2023-07-24 23:54:37 +02:00
|
|
|
#version 330 core
|
|
|
|
|
2023-08-03 10:26:01 +02:00
|
|
|
in vec3 Normal;
|
|
|
|
in vec3 FragPos;
|
|
|
|
|
2023-07-24 23:54:37 +02:00
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2023-08-03 08:43:34 +02:00
|
|
|
vec3 objectColor = vec3(1.0, 0.5, 0.2);
|
2023-08-03 10:26:01 +02:00
|
|
|
vec3 result;
|
|
|
|
|
|
|
|
// Ambient lighting
|
|
|
|
vec3 ambientLightColor = vec3(1.0, 1.0, 1.0);
|
2023-08-03 08:43:34 +02:00
|
|
|
float ambientStrength = 0.1;
|
2023-08-03 10:26:01 +02:00
|
|
|
vec3 ambient = ambientStrength * ambientLightColor;
|
|
|
|
|
|
|
|
// Directional lighting
|
|
|
|
vec3 directionalLightColor = vec3(1.0, 1.0, 1.0);
|
|
|
|
vec3 lightPos = vec3(10.0, 7.0, -8.0);
|
|
|
|
vec3 normal = normalize(Normal);
|
|
|
|
vec3 lightDir = normalize(lightPos - FragPos);
|
|
|
|
float diff = max(dot(normal, lightDir), 0.0);
|
|
|
|
vec3 diffuse = diff * directionalLightColor;
|
2023-08-03 08:43:34 +02:00
|
|
|
|
2023-08-03 10:26:01 +02:00
|
|
|
result = (ambient + diffuse) * objectColor;
|
2023-08-03 08:43:34 +02:00
|
|
|
|
2023-08-03 10:26:01 +02:00
|
|
|
FragColor = vec4(result, 1.0);
|
2023-07-24 23:54:37 +02:00
|
|
|
}
|