Download

[Tutorial] The many uses of Custom Depth in Unreal 4

Posted this in my WIP thread too, but figured the tutorial section is well suited for this too!

I explain some of the uses for this custom depth buffer like material outlines & depth culling of transparent meshes.

link to tutorial: http://www.tomlooman.com/the-many-uses-of-custom-depth-in-unreal-4/

Excerpt from the post:

“Unreal 4 introduced a new depth buffer along with their PBR rendering system. It’s called “Custom Depth” and can be used for effects like the selection outline that is built-in the Editor, rendering of occluded meshes or custom culling of transparency. I will discuss some of the basics of using this buffer in the material editor and explain some of the features I used it for in the past.”

thank you Tom :smiley:

As always you have some great simple to follow tutorials!

Thanks for sharing!

Great info! Thanks for contributing!

Thanks guys! The appreciation is appreciated! :wink:

Thanks Tom for tutorial. Infos about custom depth are really helpfull. I wonder how the “not good” effect showing another character can be usefull (like showing other characters when first is hidden to show all characters… or when in game you can see a character even when there is a wall )

Not entirely sure if this is what you mean, but I made an xray that does show players even when behind the wall.

Yes ! Exactly the idea ! So cool ! ^^ And i thought to use it when playing a hidden character too, then you see characters, meshes in background too.

Cool, I guess this could also be used for something like a predator heat view or Splinter Cell IR vision.

thank you for sharing.

No problem! Glad to share my findings :slight_smile:

I’ve tried to replicate the example where you cull the inner triangles with custom depth, but I’m not getting the depth in translucent objects.
I’ve read that you are rendering the mesh twice. What is the process to do this? I think I’ve missed something.
Thank you.

I use Blueprint to do this with two SkeletalMeshComponents (In the construct script I assign the model from the primary mesh to the 2nd component, and overwrite the material with a simple opaque material (otherwise it will not draw into custom depth, I hope this behavior changes in the future!) This really isn’t clean and I hope Epic will fix the custom depth drawing in a couple of areas (I have several others mentioned at the bottom of the post)

The sample is available here: https://github.com/tomlooman/ue4-tutorials/archive/master.zip

Great, thank you for those fantastic resources.
I managed to make it work following your sample.
I’ve encountered another problem.
I had outlined objects through blendables in the post process and I also wanted flat transparent objects like in you example, but now since they both use custom depth the transparent objects get an outline as well.
Is there a way of having some objects with only outline and some objects only flat transparent?
Thank you?

I don’t have a solution for that at the moment. I wish there was an option to have multiple buffers available or allow more manual control over the buffer in cases like this.

I wish that too.
Thank you very much.