         if (uShadowQuality == 3.0) {
             illuminated = PCF(uShadowMap, uShadowMapSize, lightUV, lightDistView - uBias);
         }
+        
+        float depth = readDepth(uShadowMap, lightUV);
+        float z = (lightDistView-uLightNear)/(uLightFar-uLightNear);
+        float z2 = (depth-uLightNear)/(uLightFar-uLightNear);
+
+        if (vPositionWorld.z > 0)
+            debugColor = hsv2rgb(vec3(z2, 1.0, 0.5));
+        else if (z < 0.0) 
+            debugColor = vec3(0.0);
+        else if (z > 1.0) 
+            debugColor = vec3(0.0);
+        else
+            debugColor = hsv2rgb(vec3(z, 1.0, 0.5));
+        /*debugColor = hsv2rgb(vec3(illuminated, 1.0, 0.5));*/
+        /*debugColor = hsv2rgb(vec3(step(lightDist, 8.0), 1.0, 0.5));*/
+        /*debugColor = hsv2rgb(vec3(step(-lightDistView, 10.0), 1.0, 0.5));*/
+        /*debugColor = vec3(lightUV, 0.0); */
     }
     
     //TODO: No kd? so not really energy conserving

    return mix(a, b, lod - upLod);
}

void main() {
    vec3 normalWorld = getNormal();
    vec3 eyeDirWorld = normalize(vEyeDirWorld);

    vec3 directSpecular = vec3(0.0);
    vec3 color = indirectDiffuse + indirectSpecular + directDiffuse + directSpecular;
    //color = irradianceColor;
    /*color = debugColor;*/
    gl_FragData[0] = vec4(color, 1.0);
    gl_FragData[1] = vec4(vNormalView * 0.5 + 0.5, 1.0);
}
