Custom Depth Mask not working

Hi

I’ve already read a couple of threads about this issue, but I’m encountering it as well using UE 5.0.3. I’ve selected my character mesh and enabled both Depth Mask and Custom Depth Mask, but whenever I select ‘Use custom depth as mask’ all I get is a green screen with no mesh visible. :-\

UnrealEditor_F0fwMV98ka

I’ve also tried enabling/disabling Custom Depth-Stencil Pass under Project Settings > Rendering.

I will say you do definitely need custom depth-stencil pass enabled. I don’t know what you’re doing with it, but you’ll probably want it enabled with stencil.

You should test to see if this works on stuff other than your player. Add some static mesh, and enable it there. Then, while still not playing, enable Custom Depth visualization:

Thanks for the reply. Okay, I’ll give that a try and see. :slight_smile:

Hmm. Well, without Custom Depth-Stencil enabled, the Custom Depth visualisation shows black:

Enabling it, there’s contrast:

However, when ticking the box to use the custom depth as mask, nothing goes green, so I’m not getting a render of the model on its own. :-\ I’ve also tried using a camera and enabling/disabling Constrain Aspect Ratio, but - same result.

I’ll assume you’re using it in a post-process material. In that case, you’ll want to make sure you have Custom Depth-Stencil Pass set to enabled with stencil. Then, change CustomDepth Stencil Value on your player character to any value higher than 0.

To preview it, here’s the setting and how it should look:

This is an example of how you can use it in a post-process material:


And this is how it shows up in game

Sorry, I might be misunderstanding, but I take it the Post Process material is a separate thing from the Post Process Volume…? I have the latter and my character is stood inside of it. Would I need to add those nodes within my current character’s materials?

Thanks

I’ve absolutely no idea what I’ve done differently, apart from re-setting up my character’s material instance and adjusting some parameters. But I’ve re-enabled the Stencil Depth in the Project Settings, hit the checkbox for the character, and the checkbox ‘Use custom depth as mask’ and it’s working correctly! :smiley:

Very odd. Does adjusting things like SSS and Roughness have any affect on the Depth Mask? That’s literally all I’ve done differently.


This is important

2 Likes

Thanks! that helped in my case.
Go to Project Settings → Rendering → Postprocessing

and set there “Custom Depth-Stencil Pass” to “Enabled with Stencil”.

now in shader you can get Custom Depth stencil value like so:

using this approach we can change outline color of different actors on level.

image

1 Like