3
$\begingroup$

Today I found something really interesting (I've never seen something like that). While debugging the buffers used in lightning, I see that the depth information is stored in what looks like cascades of depth.

UE4 Depth Buffer

What's going on there? Is that a technique to improve depth precision?

Thanks!

$\endgroup$
5
  • 2
    $\begingroup$ I've only seen something like this when someone has interpreted the bottom 8 bits of a 16- or 24-bit depth buffer as an image channel. How did you generate this image? $\endgroup$
    – Dan Hulme
    Aug 10, 2017 at 10:38
  • $\begingroup$ @DanHulme With the buffer visualiser: docs.unrealengine.com/latest/INT/Engine/UI/LevelEditor/… $\endgroup$
    – Nacho
    Aug 10, 2017 at 10:44
  • $\begingroup$ It could be a visualisation aid, instead of showing the depth as 1 gradient you can scale it to fit inside 3 steeper gradients. This is especially helpful for objects near the camera which have less variation in terms of depth. $\endgroup$
    – PaulHK
    Aug 11, 2017 at 2:43
  • $\begingroup$ @PaulHK yeah it could be, I mean, it actually repeats more than 3 times, it repeats indefinitely! $\endgroup$
    – Nacho
    Aug 11, 2017 at 8:32
  • $\begingroup$ the upper 2 bytes would have a resolution of 256*256 = 65536. If the depth buffer is 32 bits then that increases to 16777216. That may seem indefinite at first glance. $\endgroup$ Aug 11, 2017 at 11:12

2 Answers 2

1
$\begingroup$

This is just a visualisation. Type the command vis scenedepthz uv0 to see the actual depth buffer used. UE4 uses a "reversed" depth buffer for the scene.

$\endgroup$
0
-1
$\begingroup$

While I have no idea how UnrealEngine handle depth I have thought of a technique which would result in that kind of depth output.

The idea is to better manage Z-fighting by rendering multiple (stacked) frustums with shorter distance between ner and far planes. Each step in the cascade would represent one of those frustums. Using near/far plane clipping, stencil masking and optional vf-culling you can easily render the cascade front-to-back, or each frustum to each own framebuffer and consolidate afterwards, with only minor hit in performance.

This should scale better than increasing depth buffer bit depth which has diminishing returns. Besides not all platforms support high bit depth. OpenGL ES require only 16 bits!

It is just a theory though :-)

$\endgroup$
1
  • $\begingroup$ That could work. IMO it will require too much extra work and maybe the performance won't be that great! Reversed depth FTW :3 $\endgroup$
    – Nacho
    Sep 14, 2017 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.