I know, it's me again but I run into another strange problem and I am stuck in one place :\
I want to project a shadow map but renderTarget seems unable to be clamped (i set it from both xna and hlsl to pointClamp).
Even after manually clamping it in the shader It got extruded towards light position.
Picture will better explain the situation so I attach one (green line is where the projected texture should be cut off, and the ball in front of the car is lookAt point, and bellow normal buffer you see light view).
Here's HLSL code:
[source lang="cpp"]float3 DepthToPosition(float2 TexCoord){ float4 position; float d = tex2D(depth, TexCoord.xy); position.x = TexCoord.x * 2.0f - 1.0f; position.y = -(TexCoord.y * 2.0f - 1.0f); position.z = d; position.w = 1.0f; position = mul(position, InvertViewProjection); position /= position.w; return position;}float4 SpotShadow(VertexShaderOutput input) : COLOR0{ float3 Position = DepthToPosition(input.TexCoord); float4 texcoord = mul(float4(Position, 1.0), LightWorldViewProjection); if(texcoord.z < 0) return float4(1,0,0,1); texcoord.x = ((texcoord.x / texcoord.w) * 0.5 ) + 0.5; texcoord.y = ((texcoord.y / texcoord.w) * -0.5 ) + 0.5; if(texcoord.x < 0 || texcoord.x > 1 || texcoord.y < 0 || texcoord.x > 1) return float4(1,0,0,1); float LightDistance = (tex2D(shadow, texcoord.xy)); return LightDistance;}[/source]
I think I don't have to say i want to get rid of this if that is checking coords
But also I want to know why does it extrude projected texture towards light camera and how to reapir it
Thank You in advance
Edited by Tasaq, 08 August 2012 - 07:24 AM.






