 
 void main() {
     vec3 lightIntensity = material.ambient * ambientColor;
-    for (uint i = 0u; i < nbLights; ++i)
+    float fogFactor = computeFogFactor();
+    if (fogFactor < 1.0)
     {
-        lightIntensity += lightSources[i].color * phongModel(lightSources[i].position);
+        for (uint i = 0u; i < nbLights; ++i)
+        {
+            lightIntensity += lightSources[i].color * phongModel(lightSources[i].position);
+        }
     }
+    lightIntensity = mix(fogInfo.color, lightIntensity, fogFactor);
+
     fragColor = vec4(lightIntensity, 1.0);
 }

    vec3(.6),
    40
};

vec3 phongModel(in vec4 lightPosition)
{

smooth in vec3 fragNormal;

out vec4 fragColor;

struct FogInfo
{
    float minDistance;
    float maxDistance;
    vec3 color;
};

struct LightSource
{
