   discontinuity in DPSM hemisphere transition
  Hi,  I've been implementing dual paraboloid shadow mapping and I got it to work except for one nasty glitch. When the shaders switch from the front paraboloid shadow map to the back paraboloid shadowmap there is a discontinuity in the shadows :http://www.starmen.nl/dualparaboloid.pngthere is a break in the shadow cast by the ring on the globe exactly at the boundary of the two shadowmaps.** edit **I've changed toe shader code to better suit the paper I read, but there's still a hitch at the shadow map boundary** edit **part of the shadow map vertexshader (unpolished rough draft!):// (dual) Paraboloid shadow mapping    output.position = mul(input.position, C_LIGHTVIEWMATRIX);    output.position.z *= C_HEMISPHERE;    // 1 or -1    if ( output.position.z >= 0.0f ) {  float lenP = length(output.position);  output.position /= lenP;  output.position += float4( 0.0, 0.0, 1.0, 0.0 );  output.position.xy /= output.position.z;  output.position.z = (lenP-1.0)/(1000.0-1.0)+0.01f;  output.position.w = 1.0;  output.depthposition = output.position.z;    } else { output.depthposition = 0.0f;    }and the part of the shader that used the shadow maps (unpolished rough draft!):   float4 p = mul( vector (input.vertexpos,1), C_LIGHTVIEWMATRIX );    float l_hemisphere = p.z;    float lenP = length(p);    p /= lenP;    if ( l_hemisphere >= 0.0f ) { p.z+=1.0f;    } else { p.z-=1.0f;    }    p.xy /= p.z;    p.z = (lenP-1.0)/(1000.0-1.0)+0.01f;    l_vertex_depth.z = p.z;    l_shadowcoord.xy = (0.5 + 0.5*p).xy;// Strange tinkering with texture coords, no idea why it is needed but it is    if ( l_hemisphere > 0.0f ) { l_shadowcoord.y = 1- l_shadowcoord.y;    }    if ( l_hemisphere < 0.0f ) { l_shadowcoord.x = 1- l_shadowcoord.x;    }    l_shadowfactor=0;    l_shadowtexturecoord.xy = (0.5 + 0.5*p).xy;    if ( l_hemisphere >= 0.0f ) { l_shadowfactor+=( tex2D(TEXSHADOW1,l_shadowtexturecoord.xy).r > l_vertex_depth.z );    } else { l_shadowfactor+=( tex2D(TEXSHADOW2,l_shadowtexturecoord.xy).r >l_vertex_depth.z );    }Any idea where the discontinuity comes from ?Regards,Ebrarian[Edited by - ebrarian on August 9, 2008 3:13:06 PM]
  Looks like you forgot to divide the xy by the z component. This is how I calculate it:float L = length(pos);float3 P0 = pos / L;P0.z = P0.z + 1;P0.x = P0.x / P0.z;P0.y = P0.y / P0.z;P0.z = L / LightAttenuation;P0.x = .5f * P0.x + .5f;P0.y = -.5f * P0.y + .5f;You should always have to invert the y tex coord if you're sampling a D3D texture.   ;  Thanks,  but if you look at my shaders you'll notice the linesoutput.position.xy /= output.position.z;andp.xy /= p.z;where xy is divided by zalso, the inversion of the y coordinate is replaced with inversion of the x coordinate on the opposing hemisphere which makes no sense to me.I think the problem is caused by tearing at the edge of the shadowmap :http://www.starmen.nl/tearing.png(I added a huge box to the scene which completely envelops the globe, the depth values are exaggerated to be able to see the shadow map)I tried moving theif ( output.position.z >= 0.0f ) {check from the vertex shader to the pixel shader, but that gives strange results. The tears go away but some sort of fog-like fuzzyness is introduced.Regards,Ebrarian   ;  Ah, sorry. I was thinking that the first block was the construction pass.   