I am having suffering due to lack of precision in the following function in glsl:
double LinearizeDepth(double depth)
{
double z = depth * 2.0 - 1.0; // back to NDC
return (2.0 * near_plane * far_plane) / (far_plane + near_plane - z * (far_plane - near_plane));
}
I want to threshold on a depth value like so
abs(linearised_depth - threshold_value) < epsilon
and my code works as expected when epsilon >= 0.5. I want to reduce epsilon to ~0.1. Are there any tricks to help with this?