Original Post
Hey guys,
I'm currently working on an SSAO implementation, and therefore needed the depth buffer values. After doing some research, I found many places (most of them posts on this forum) that said to use this function:
However, I can't figure out WHY this works, and I couldn't find an explanation anywhere. I know it has something to do with how the depth is generated when transforming by the projection matrix.
Could someone enlighten me? And what's the 2.0 for?
I'm currently working on an SSAO implementation, and therefore needed the depth buffer values. After doing some research, I found many places (most of them posts on this forum) that said to use this function:
(2.0 * Near) / (Far + Near - depth * (Far - Near))However, I can't figure out WHY this works, and I couldn't find an explanation anywhere. I know it has something to do with how the depth is generated when transforming by the projection matrix.
Could someone enlighten me? And what's the 2.0 for?