Zbuffer

Hi, I would like to know how is calculate the Zbuffer in blender. I mean which algo is used to have more precision when it’s near and less when is far. Log2? Ln? log10? Or something else.

Check zbufclip() in zbuf.c

ok, pretty complicate, how would you do to have the Zbuffer value in 3d world.
For eg pixel(0,0) have Z = 10. It seems Z values are not linear, I need to “invert” or “linearize” the value.
Actually I want to make a simple addon that build a point cloud from an image with Z value (EXR) to the 3d
view.
All work but there a problem with the Z values.
I join a .blend:
http://www.pasteall.org/blend/19259
1: make a render with f12
2: execute the script
3: go in 3d view (camera view) > spacebar > Simple Object Operator
Now turn the view to see the point cloud from side.
It normaly have to be on the mesh, but it’s curved, it’s only correct when it’s on the grid floor.
If someone have an idea.
Thanks