Download

Scene Depth Precision

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.

Any help much appreciated

2m sphere at ~70m range

74809cec3916b692492398a9d2ffe04962b12b24.png d2aeab52682ebcc07f8479bbedb7d91a9b821765.png

I’m using SceneCapture2D and the following postprocess material (replacing tonemapper)
237ab96ddc24a8353a08edd45dddc95dfdd56465.png

Render target settings
945c7c19ccb01af76a0a61e25b06b5a484cb12bf.png

You may have to change the far clipping plane, unfortunately I don’t think that’s easily exposed.

thanls for suggestion, but changing near or far clipping plane made no difference, maybe its just the 16bit float textures used by gbuffer ?

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.

try entering in r.gbufferformat 5 perhaps.

Do you really want DXT compression on this RT?