Original Post
Hello everyone! Ok, basically I want to implement nice shadow mapping in my DX10 engine. I read a lot and checked multiple samples before starting to implement it myself. I started out with basic PCF filtering, and will later add support multiple lights, omnidirectional (cubemap) shadow for the point light. Then I planned to use Summed-Area Variance Shadow Maps but I don't have access to GPU Gems 3 DVD so I'll probably use normal VSM or ESM instead and forget about penumbra. My principal problem is that most examples I find on internet are for SM2.0 and DX9 and don't take advantage of DX10. I finally decided to base myself mostly on NVIDIA SDK VSM sample, which use DX10 and look nice. Anyway, my problem is not DX10 related at all and might be pretty stupid. I've been searching for many hours now and can't put my finger on the problem. I have a simple scene with one floor and two balls, with the light attached to the right of the controllable one and facing to the right. With only Phong shading it look like this:
If I render my depth map texture instead of the diffuse one I can clearly see the camera view on the floor, and it is correct IMO :
But unfortunately, if I project it into my camera view and use a PCF filter, it get an offset and don't render the shadow at the good place:
I use similar PCF and projection code as the nvidia sample, but it is the same idea as everywhere else. I might get mixed up in the format, I don't have any rendertarget for the light pass (pass NULL to OMSetRenderTarget) and only use a depthstencil texture with no multisample for now. Here are the formats used, are theses ok?: D3D10_TEXTURE2D_DESC = DXGI_FORMAT_R32_TYPELESS D3D10_DEPTH_STENCIL_VIEW_DESC = DXGI_FORMAT_D32_FLOAT D3D10_SHADER_RESOURCE_VIEW_DESC = DXGI_FORMAT_R32_FLOAT I clear it to 1.0f. I also change the viewport size before render the shadow map to match the texture size (512*512 for now). The light viewProj matrix use a D3DX_PI * 0.5f fov and a 1.0f aspect ratio. My HLSL shader code can be viewed there: http://gamedev.pastebin.com/me9d0c17
If I render my depth map texture instead of the diffuse one I can clearly see the camera view on the floor, and it is correct IMO :
But unfortunately, if I project it into my camera view and use a PCF filter, it get an offset and don't render the shadow at the good place:
I use similar PCF and projection code as the nvidia sample, but it is the same idea as everywhere else. I might get mixed up in the format, I don't have any rendertarget for the light pass (pass NULL to OMSetRenderTarget) and only use a depthstencil texture with no multisample for now. Here are the formats used, are theses ok?: D3D10_TEXTURE2D_DESC = DXGI_FORMAT_R32_TYPELESS D3D10_DEPTH_STENCIL_VIEW_DESC = DXGI_FORMAT_D32_FLOAT D3D10_SHADER_RESOURCE_VIEW_DESC = DXGI_FORMAT_R32_FLOAT I clear it to 1.0f. I also change the viewport size before render the shadow map to match the texture size (512*512 for now). The light viewProj matrix use a D3DX_PI * 0.5f fov and a 1.0f aspect ratio. My HLSL shader code can be viewed there: http://gamedev.pastebin.com/me9d0c17

