How to get real depth value from depth buffer

Discussion in 'Visualization' started by JerryWong, Sep 1, 2019.

  1. Hi, I just want to calculate real depth values from depth buffers with mjr_readPixels as follows:

    #input :
    z_n is the depth buffer
    zFar= 10.0
    zNear = 0.01

    z = z_n *2 -1
    z_e = zFar*zNear / ( zFar+zNear - (zFar - zNear)*z )

    But it couldn't get the correct depth values. Have you ever guess where this error comes from?

    Thank you!