Maybe someone can elaborate. For a more detailed description of the problem (with images) I would invite you to read my post there:
I do have a test-project for a new (cleaned up) deferred pipeline, where I do save the viewspace depth (viewpos.z) in a buffer and want to recreate the (viewspace) position of a pixel from that depth buffer. I use a Corner Frustum together with an aligned Fulscreen Quad in order to get the View Direction of that pixel which is then multiplied by the stored depth from the gbuffer pass.
float depth = tex2D(sampler_depth, input.UV).g; float3 position = depth * ViewDirection;
For testing purposes I also write the Viewspace Position to a buffer to compare the result. Unfortunately, it turns out, that my calculated position from depth seems to have an inverted y-axis.
I have a feeling, that his may be related to handiness. XNA is right-handed so I guess, Monogame is as well. I think I have everything correctly in that mind, but the results say otherwise.
Can anyone point me where I do the things wrong? i.e. if I invert the y-axis in the CornerFrustum, I get the correct position (according to outputing on screen, which then is equal to the buffer), but if I apply a Projection Matrix to it:
float4 ppos = mul(float4(position,1), Projection); float2 uv = 0.5f * (ppos.xy / ppos.w) + float2(0.5f, 0.5f);
the result is all mirrored. Looks like, there is something I don’t understand fully … is it handiness? the fact, that viewspace depth is negative in XNA/monogame?
trivia: I use that position for SSAO and my current workaround is to invert the sample kernel as well to accomodate the inverted y-axis - but I am still interested why I do not get the expected result from the reconstruction of the position.