   
   if(numBlockers == 0) return vec2(-1.0, numBlockerSearchSamples);
   else if (numBlockers == numBlockerSearchSamples) return vec2(-2.0, 0.0);
-  else return vec2(Depth2Distance(avgBlockerDepth / float(numBlockers), zNearFarInv), float(numBlockerSearchSamples - numBlockers));
+  else return vec2(Depth2Distance(avgBlockerDepth / numBlockers, zNearFarInv), numBlockerSearchSamples - numBlockers);
 }
 
 // Compute visibility of given texture coordinate subject to given shadow coverage circle


vec2 BlockerDistance(sampler2D depthTex, vec4 texCoord, vec3 coverageCircle, vec2 zNearFarInv, float planeSign)
{
  int numBlockerSearchSamples = 8;
  int numBlockers = 0;
  float avgBlockerDepth = 0.0;
  vec2 center = coverageCircle.xy; // Extract shadow coverage circle center
  float radius = coverageCircle.z; // Extract shadow coverage circle radius
  float phi = random(texCoord.xy)*TWOPI;
  vec3 sampleTexCoord = texCoord.xyz;
  float depth;
  
  // Include depth at the fragment since that is guaranteed knowledge
  depth = texture2D(depthTex, texCoord.xy).r;
  if ((depth != (0.5 - planeSign*0.5)) && (planeSign*depth > planeSign*sampleTexCoord.z))
  {
    ++numBlockers;
    avgBlockerDepth += depth;
  }
  
  for (int i = 1; i < numBlockerSearchSamples; ++i)
  {
    // Get sample coordinates
    vec2 offset = VogelDiskSample(i-1, numBlockerSearchSamples-1, phi) * radius;
    sampleTexCoord.xy = center + offset;
    
    // Lookup sample depth and compare it to fragment depth

    sampleTexCoord.xy = center + offset;
    
    float depth = texture2D(depthTex, sampleTexCoord.xy).r;
    blockers += ((depth != (0.5 - planeSign*0.5)) && (planeSign*depth > planeSign*sampleTexCoord.z)) ? 1.0 : 0.0;
  }
  
  return vec2(numSamples-blockers, numSamples);
}

void main(void)
