   Converting depth value to linear value
  How can I convert the depth value, [0, 1], to a linear value in the same range [0, 1]? My feeble math skills says this'll absolutely need the near ad far clip plane distances, but other than that I've no idea. I'd appreciate any help.TIA[Edited by - Starfox on July 11, 2006 5:53:23 AM]
  Hm not sure if I got your question right.I would simply calculate the distance to the near plane and divide by (dist_far-dist_near). Then you have linear distance in [0,1].If you want to convert your existing depth values to the linear range, i won't be able to help.   ;Found this link in my bookmarks;  I need to avoid rerendering the scene, or changing the vertex shader. I need to strictly read the z value at this pixel and output a linear (W-buffer-like) value.   ;  Is it just 1 piexls depth you need?;  Well, u can try thisa=-far/(far-near)b=-far*near/(far-near)Z=(a*z+b)/-zwhere 'z' is your z value read from z-buffer, and 'Z' is your real distance...but if somebody knows how to do that with infinite far plane, please tell me!!   ;  Thanks Coluna, rating++   