2
$\begingroup$

I try to export precise depth information from Eevee's z-buffer, however on gentle slopes it produces a step effect, which led me to believe the Eevee's z-buffer might use half precision floats to store its depth. Can I increase the precision of Eevee's z-buffer or access the higher precision depth somehow without applying a special material to my object? I'd need the full precision as I try to construct a precise depth-map to generate ground truth for a scientific application.

The precise depth seems to be there, because when I access the depth information via the Camera Data using a custom material and render the slope with that applied, I get a nice gradient. The same is true for the Cycles renderer, however, I'd like to use Eevee because it is much faster, and I do not need any other fancy features.

The scene I'm rendering is a simple plane with a 5-degree slope and a perspective camera looking down on it.

scene of gentle slope with camera looking down

The following render was produced by feeding the normalized depth information of the Render Layer to the Composite node, resulting in the mentioned step effect:

step effect of rendered z-buffer

However, using this simple shader where I just feed the Camera Data View Z Depth to the Material Surface...

shader nodes feeding z-depth to surface

... I get the nice gradient I'm looking for:

nice depth gradient

Nonetheless, I'd prefer using the z-buffer directly, because switching materials complicates my setup, and as of now Eevee doesn't seem to support global material overrides.

$\endgroup$
2
  • $\begingroup$ I've tried, it seems Cycles have no such problems. $\endgroup$
    – Crantisz
    Oct 14, 2021 at 12:35
  • 1
    $\begingroup$ Thanks for the hint, yes, Cycles produces the desired result, however, I'd like to use Eevee because it is much faster, and I do not need the extra features of Cycles (except for the high-precision depth buffer apparently). I've now updated my question accordingly. $\endgroup$
    – swamy
    Oct 14, 2021 at 13:50

2 Answers 2

2
$\begingroup$

Full precision that you are after is possible with Cycles. I would definitely use Cycles for this. If you only need depth pass, you can set it up to render as fast or even faster than EEVEE. Just set the samples to 1 and bounces to 0:

enter image description here

You can render depth pass only in Cycles and your image in EEVEE.

It is not logical to choose the render engine based on the fact that you do not need it's other existing features. Makes sense to chose it because it has the feature you need the way I see it.

$\endgroup$
1
  • $\begingroup$ Thanks for the answer, turning down Cycles to a bare minimum for the depth buffer render is a good workaround for me. I'm guessing I'd need to look into the EEVEE implementation itself to change the depth buffer precision. $\endgroup$
    – swamy
    Oct 18, 2021 at 17:14
1
$\begingroup$

Try using the Mist Pass.

Under Properties > View Layer Properties > Passes > Data enable Mist

enter image description here

Then, select your Camera, and under Properties > Object Data Properties > Viewport Display check Mist, then, under Properties > World Properties > Mist Pass, you can adjust the start and end points where the pass will be calculated.

enter image description here enter image description here enter image description here

Enable Compositing and connect the Mist output of the Render Layer to the Composite node. Render it out and you'll get this:

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks for your response, this works great as a first workaround, as with this method I can use the float resolution more effectively. However, I wonder if I can configure the renderer to use full precision, as the Camera Data node in the Shader editor provides this data anyway. $\endgroup$
    – swamy
    Oct 14, 2021 at 14:46
  • $\begingroup$ To be honest, the mist pass is much more useful, because you can precisely tell its start and end points, which you can use to perfectly accommodate your specific scene. With Z depth, it's fixed, and you can't really customize the falloff. Depends on what you want to use this for, really. If it's for very technical/scientific purposes, mist might not be ideal, it's more for aesthetic purposes like adding fog to a scene. $\endgroup$
    – Geri
    Oct 14, 2021 at 15:03
  • $\begingroup$ In my case it is for scientific purposes, hence I'd prefer the full precision if it is possible. Thanks for the feedback, I'll update my question accordingly. $\endgroup$
    – swamy
    Oct 14, 2021 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .