I'm trying to understand how to restore the z from the depthbuffer and trying to do the math, based on these two posts:
Getting the true z value from the depth buffer (stackoverflow) http://ogldev.atspace.co.uk/www/tutorial46/tutorial46.html
The two posts use different projection matrices (specifically the lower-right 2x2 part is different, one difference being use of a -1 vs a +1 in [ 3 ][ 4 ]). Not really sure why that would be, afaik the one with -1 is "the correct OpenGL projection-matrix" (right?)
Now I tried to do the calculation for both and the weird thing is that in the SO-post it mentions -A-B/z (or in my calculation -S-T/z). Then the code shows
And solving this for A and B (or S and T) gives
Okay, now doing the calculation for both Projection-matrices from scratch, (left=ogldev.atspace.co.uk, right=stackoverflow) and now it gets confusing because up to the -S-T/z part everything is fine, but when we compare the solved formula for which should have been the stackoverflow-case (-1 projection-matrix) it matches the one from ogldev.atspace.co.uk (+1 projection matrix) - colored in red...
this is confusing, any clues what I'm doing wrong?!