Getting depth from rendertarget2d in shader


I’ve been stuck on this problem for a little bit. I’m drawing drop shadows in my game all to a single rendertarget and then drawing that rendertarget onto the scene, this way overlapping shadows don’t stack alpha. I’ve recently changed how I’m handling depth buffering though and I’ve run into a problem. I can render all the drop shadows properly into the rendertarget, but when I want to draw the rendertarget on the screen I have no idea how to retain the depth of the drop shadows.

I’ve tried converting the Depth to the RGB of the shadow, but I’m not sure this is possible without creating rounding errors that cause stacking artifacts. So if it’s possible to just use the already existing depth information that’d be great.