1 | initial version |
The method for de-linearizing the value of the depth buffer is to use the following formula:
real_depth = 2 * near * far / (far + near - (2 * depth - 1) * (far - near))
where: - real_depth is the actual depth value in world units - near is the distance to the near clipping plane - far is the distance to the far clipping plane - depth is the depth value read from the depth buffer, which is typically in the range of [0, 1]
This formula accounts for the non-linear distribution of depth values in the depth buffer and maps them back to the actual depth values in world units.