Dual paraboloid map issues.

Hi all, I have generated my dual paraboloid shadow map into two textures. And, now I’m reading off the two textures and determine if they are in shadow with this sample code snippet.

// Get the shadow coordinate in light perspective
vec4 lviewPos = lightViewMat * worldCoord;
//lviewPos = lviewPos/lviewPos.w; //Same as dividing by 1 since perspective is Identity mat

float len = length(lviewPos.xyz);
vec3 lightDir = lviewPos.xyz/len;

float DPDepth;
if(lightDir.z >= 0)
{
float zSum = 1.0f + lightDir.z;
vec2 texFront;
texFront.x = ( lightDir.x / zSum ) * 0.5f + 0.5f;
texFront.y = ( lightDir.y / zSum ) * 0.5f + 0.5f;

DPDepth = texture(DPFrontSampler, texFront).z;	

}
else
{
float zSum = 1.0f - lightDir.z;
// for the back the z has to be inverted
vec2 texBack;
texBack.x = ( lightDir.x / zSum ) * 0.5f + 0.5f;
texBack.y = ( lightDir.y / zSum ) * 0.5f + 0.5f;

DPDepth = texture(DPBackSampler, texBack).z;

}

float sceneDepth = (len - nearDistance)/(farDistance - nearDistance);
if ( DPDepth < sceneDepth) // In Shadow
{ …}

I look through the papers and still can’t figure out whats wrong with it.