Original Post
Hey! I am rendering a pointlight shadowmap and it works fine except for when I zoom my camera out a bit and rotate I have a specific point(works good mostly when rotating) when most shadows(those furthest away) is switching place by just a tiny bit but noticable. I can rotate the camera back and forth around that point to watch my shadows jump back and forth with it. What can be causing this? Here is a picture trying to describe whats happening. Blue is before an red is after. http://img89.imageshack.us/img89/5782/shadowjump.jpg This is my VertexShader: SSceneVertexToPixel Scene_Shadow_BumpVS( float4 inPos : POSITION, float2 inTexCoords : TEXCOORD0, float3 inNormal: NORMAL0, float3 inTangent : TANGENT) { SSceneVertexToPixel Output = (SSceneVertexToPixel)0; float4x4 xLightWorldViewProjection = mul(mWorld, mLightViewProjection); float4 ShadowMapSamplingPos = mul(inPos, xLightWorldViewProjection); float3x3 worldToTangentSpace; worldToTangentSpace[0] = mul(inTangent,mWorld); worldToTangentSpace[1] = mul(cross(inTangent,inNormal),mWorld); worldToTangentSpace[2] = mul(inNormal,mWorld); Output.Light = normalize(mul(worldToTangentSpace,vLightDir)); Output.Position = mul(inPos, mWorldViewProjection); Output.RealDistance = ShadowMapSamplingPos.z/fMaxDepth; Output.TexCoords = inTexCoords; Output.ProjectedTexCoords[0] = ShadowMapSamplingPos.x/ShadowMapSamplingPos.w/2.0f +0.5f; Output.ProjectedTexCoords[1] = -ShadowMapSamplingPos.y/ShadowMapSamplingPos.w/2.0f +0.5f; return Output; } This is my Pixelshader: SScenePixelToFrame Scene_Shadow_NormalPS(SSceneVertexToPixel PSIn) { SScenePixelToFrame Output = (SScenePixelToFrame)0; // Get the DiffuseTexture float4 texCol = tex2D(ColoredTextureSampler, PSIn.TexCoords); // Add the colors together Output.Color = texCol; Output.Color.rgb *= (vLightColor + fAmbient); if ((PSIn.RealDistance.x - 1.0f/100.0f) > tex2D(ShadowMapSampler, PSIn.ProjectedTexCoords).x) { Output.Color *= (1-fShadowColor); return Output; } return Output; } EDIT: For some reason I had to do this part in the pixelshader.. Output.ProjectedTexCoords[0] = ShadowMapSamplingPos.x/ShadowMapSamplingPos.w/2.0f +0.5f; Output.ProjectedTexCoords[1] = -ShadowMapSamplingPos.y/ShadowMapSamplingPos.w/2.0f +0.5f; [Edited by - Typon on September 24, 2009 6:11:56 PM]