Skip to main content
GameDev.net gamedev.net
🔒 Locked

Mapping Depth Values to the near / far range

Started by wolf Nov 21, 2009 at 1:00 AM 1 replies 2.6k views
Original Post
wolf
wolf
Hi, I have a projection matrix that is w, 0, 0, 0, 0, h, 0, 0, 0, 0, (f + n) / (f - n), -(2 * f* n) / (f - n), 0, 0, 1, 0); This matrix is a OpenGL projection matrix. I would like to map the values that I can read from the depth buffer into the near / far plane range of the view frustum in camera space. This is useful for camera based effects like Depth of Field. Many websites suggest a solution like this: -f * n /(z * (f-n) -f) where z is the depth buffer value and f and n the far and near plane. Any references where I can read up on this?
Halifax2
Halifax2
Sorry to bump, but this link would be good for you and any future prosperity when they search the forums. It does a very good explanation of the derivation of the perspective projection matrix, thus explaining why the depth map is not linear: Deriving Projection Matrices: Perspective Projection.
Denzel Morris (@drdizzy) :: Software Engineer :: SkyTech Enterprises, Inc.
"When men are most sure and arrogant they are commonly most mistaken, giving views to passion without that proper deliberation which alone can secure them from the grossest absurdities." - David Hume

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.