This is the calculation for rate of change in the zbuffer
per distance in view coordinates

Use the following vars to simplify the calc.
mat is the ViewToDeviceMatrix

A = mat[0][0]
B = mat[0][2]
C = mat[2][2]
D = mat[2][3]
E = mat[0][3]

Z = View Coord Z value
S = space (distance in View coords) to move
Zdc = Z in device coords
Zdb = Z in depth buffer coords

==============================================================
==============================================================
Ortho case

Zdc1 = C * Z + D
Zdc2 = C * Z + C * S + D
dZdc = C * S
dZdb = C*S*2.0

==============================================================
==============================================================
Perspective case

Zdc = (C*Z + D)/-Z
Zdc = -C - D/Z
Zdc + C = - D/Z
Z*(Zdc + C) = -D
Z = -D/(Zdc + C)

Z2 = Z + S

Zdc2 = (C*Z2 + D)/-Z2
Zdc2 = - C - D/Z2
Zdc2 = - C - D/(Z + S)

dZdc = - D /(Z+S) + D/Z


float fragDepthToVCDepth(float fdepth)
{
  vec4 tmp = vec4(0.0,0.0, fdepth*2.0 - 1.0, 1.0);
  vec4 result = DCVCMatrix * tmp;
  return result.z/result.w;
}

float fragCoordsToVC(vec4 fragCoords)
{
  vec4 tmp = vec4(0.0,0.0, fdepth*2.0 - 1.0, 1.0);
  vec4 result = DCVCMatrix * tmp;
  return result.z/result.w;

  vec4 tmp = vec4(0.0,0.0, fdepth*2.0 - 1.0, 1.0);
  vec4 result = DCVCMatrix * tmp;
  return result.z/result.w;
}

float VCdepthDCdepth(float vcdepth)
{

}

vec3 DCtoVC(vec3 dc)
{
  vec4 vc = vec4(dc.x*2.0 -)
    float x  = texCoord.x * 2.0 - 1.0;
    float y  = texCoord.y * 2.0 - 1.0;
    float zn = ((farZ + nearZ) / (farZ - nearZ) * eyeDepth + 2 * farZ * nearZ / (farZ - nearZ)) / eyeDepth;

    vec4 clipPos = vec4(x, y, zn, 1.0f);
    vec4 viewPos = DCVCMatrix * clipPos;
    return viewPos.xyz / viewPos.w;

}


vec3 DepthToVC(float depth) {
    float x  = texCoord.x * 2.0 - 1.0;
    float y  = texCoord.y * 2.0 - 1.0;
    float zn = ((farZ + nearZ) / (farZ - nearZ) * eyeDepth + 2 * farZ * nearZ / (farZ - nearZ)) / eyeDepth;

    vec4 clipPos = vec4(x, y, zn, 1.0f);
    vec4 viewPos = DCVCMatrix * clipPos;
    return viewPos.xyz / viewPos.w;
}
