     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

////////////////
// ATTENUATION
/////////////
float getLightAttenuation(const in float distance, const in float constant, const in float linear, const in float quadratic)
{
    return 1.0 / ( constant + linear*distance + quadratic*distance*distance );
}
///////////////
// SPOT CUT OFF



vec4 computeSunLightShading(

                            const in vec3 normal,
                            const in vec3 eyeVector,

                            //const in vec4 u_materialAmbient,
                            //const in vec4 u_materialDiffuse,
                            //const in vec4 u_materialSpecular,
                            //const in float u_materialShininess,

                            const in vec4 lightAmbient,
                            const in vec4 lightDiffuse,
                            const in vec4 lightSpecular,

                            const in vec3 lightDirection)
{
  // compute dist
  // compute NdL   // compute NdL
  float NdotL = dot(lightDirection, normal);
  if (NdotL > 0.0)
    {
      bool isShadowed = false;
      // compute shadowing term here.
      // 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 + diffuseContrib*specularContrib*shadowContrib;
        }
    }
  return vec4(0.0);
}

vec4 computePointLightShading(
                              vec3 normal,
                              vec3 eyeVector,

                              // const in vec4 u_materialAmbient,
                              // const in vec4 u_materialDiffuse,
                              // const in vec4 u_materialSpecular,
                              // const in float u_materialShininess,

                              vec4 lightAmbient,
                              vec4 lightDiffuse,
                              vec4 lightSpecular,

                              vec3 lightDirection)
{
  // compute dist
  Vec3 lightVector = lightSpotPosition - vertexPosition;
  float dist = length(lightVector);
  // compute attenuation
  float attenuation = getLightAttenuation(dist, lightAttenuation.x, lightAttenuation.y, lightAttenuation.z);
  if (attenuation <= 0.0)
    {
      // compute direction
      vector3 lightDirection = dist > 0.0 ? lightVector / dist :  vec3( 0.0, 1.0, 0.0 );
      // compute NdL
      float NdotL = dot(lightDirection, normal);
      if (NdotL > 0.0)
        {
          bool isShadowed = false;
          // compute shadowing term here.
          // 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;
          }
        }
    }
  return vec4(0.0);
}
