I’m trying to render the scene depth to a render target. I have this working but the depth resolution is poor, see graph below (scene is a sphere, so should be smooth curve).
precision get worse with range. I need this to work at long range with small field of view.
I have compiled the engine with the “DEPTH_32_BIT_CONVERSION=1” define and this reduced z fighting issues but made no difference to final result rendered in render target.
Most likely depth buffer is 16bit, 32 is really an overkill for most of the cases. If changing far and near plane doesn’t work then I suggest changing the way how vertices are transformed in vertex shader and doing reverse transformation of depth in the next step that you do on saved image. Another thing to try is remove compression from texture when you save it.