     const in float lightCosSpotCutoff,
     const in float lightSpotBlend)
 {
-    // compute distance
+    // compute dist
     Vec3 lightVector = lightSpotPosition - vertexPosition;
     float dist = length(lightVector);
     // compute attenuation
-    float attenuation = getLightAttenuation(distance, lightAttenuation.x, lightAttenuation.y, lightAttenuation.z);
+    float attenuation = getLightAttenuation(dist, lightAttenuation.x, lightAttenuation.y, lightAttenuation.z);
     if (attenuation <= 0.0)
     {
         // compute direction



vec4 computeSunLightShading(
    vec4 materialAmbient,
    vec4 materialDiffuse,
    vec4 materialSpecular,
    float materialShininess,

    vec4 lightAmbient,
    vec4 lightDiffuse,
    vec4 lightSpecular,

    vec3 normal,
    vec3 eyeVector,

    vec3 lightDirection)
{

    // compute distance
    // compute NdL
    float NdotL = max(dot(lightDirection, normal), 0.0);
    if (NdotL != 0.0)
    {
        bool isShadowed = false;
        // compute shadowing term here.
        // isShadowed = computeShadow(shadowContrib)
        if (!isShadowed)
        {
            computeDiffuse(diffuseContrib);
            computeSpecular(specularContrib);
            return lightAmbient*MaterialAmbient + diff*spec*shadowContrib;
        }
    }
}

vec4 computePointLightShading(
    vec4 materialAmbient,
    vec4 materialDiffuse,
    vec4 materialSpecular,
    float materialShininess,

    vec4 lightAmbient,
    vec4 lightDiffuse,
    vec4 lightSpecular,

    vec3 normal,
    vec3 eyeVector,

    vec3 lightDirection)
{
    distance = computeDistance();
    // compute attenuation
    float attenutation = computeAttenuation();
    if (attenuation != 0.0 )
    {
        Direction = computeDir;
        // compute NdL
        float NdotL = max(dot(lightDirection, normal), 0.0);
        if (NdotL != 0.0)
        {
            bool isShadowed = false;
            // compute shadowing term here.
            // isShadowed = computeShadow(shadowContrib)
            if (!isShadowed){
                computeDiffuse(diffuseContrib);
                computeSpecular(specularContrib);
                return lightAmbient*MaterialAmbient + attenuation*diff*spec*shadowContrib;
            }
        }
    }
    return vec4(0.0);
}

                    // isShadowed = computeShadow(shadowContrib)
                    if (!isShadowed){
                        vec3 diffuseContrib;
                        lambert(NdotL, u_materialDiffuse.rgb, LightDiffuse.rgb, diffuseContrib);
                        vec3 specularContrib;
                        specularCookTorrance(normal, lightDirection, eyeVector, u_materialShininess, u_materialSpecular.rgb, lightSpecular.rgb, specularContrib)
                            return lightAmbient*u_materialAmbient + attenuation*spotblend*diffuseContrib*specularContrib*shadowContrib;
                    }
                }
            }
