I'm trying to draw a depth map of a scene. Now, I made an HLSL file like the one in: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Shadow_map.php And everything went just fine. However! I want to find out the exact value of each pixel, so instead of drawing on the normal render target, I created a new render target which is a Texture2D as in: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Render_to_texture.php and then I drew it using a spritebatch.
Then! when I display the images, the first, that is, the one drawing directly to the screen gives this output:
and the one that draws to a texture then to the screen using a sprite gives this:
Notice how in the second capture, the right arm of the body, which is obviously behind the body, is drawn as if the body doesn't exist in the overlapping area.
I think, its an ordering problem, as the vertices in the front are drawn first to the texture then the more distant ones overwriting the closer ones resulting in the observed image.
I would appreciate any input.