Custom depth and transparent material

There are several old messages/bug reports about how transparent objects don’t add to “custom depth”, which would be handy for several effects.

However, in this reddit thread, “Kazuja” appears to have done it, yet I can’t reproduce the effect and neither one of us can figure out why.

Anyone know what might be going on?

Bumping this, because I’m in the same boat. I’d like to avoid having to manually duplicate and render everything twice just to get a depth pass on some translucent objects. Searching on google, these forums, and documentation comes up with nothing but questions from users and absolute radio silence from Epic on the issue.

Answerhub question
Answerhub question
Forum post mentioning the issue in some of the comments

I tried the same setup as the Kazuja guy as well (which is nothing really, just apply a translucent material and tick Render CustomDepth Pass) to no avail as well.

Translucent materials won’t write in the scene/custom depth buffer no matter what you are going to try… they are simply rendered later in the pipeline.
Duplicating the meshes is the only option for now unless something dramatic has changed in latest engine version (not likely).

Correct. I replied to those 2 answerhub questions. It is funny that both of them were asked by somebody who is now an Epic employee.

I know this is an old thread, but maybe something has changed in the meantime.
Is there no way at all to set an outline for a mesh that has a translucent material?

Have the same question. For me somehow “Allow Custom Depth Write” flag on translucent material enables Custom Depth only in case if opacity is above 35% and if opacity goes below that it stops working on per pixel basis. That look like a bug. More interesting note that in additive material it works fine. That is in UE4.25.

2 Likes

I noticed exactly the same issue with this 35%, really weird!

That 35% is coming from alpha cutout threshold. Transparent materials that are rendered in custom depth pass are using depth only shader variant but because transparent materials does not write depth masked variation of depth only shader is used instead. I added custom node that alternate behavior when render pass is depth only.

That did work. Just changed alpha cutout threshold, and it did the trick. Though it’s really weird behavior highly unintuitive and moreover undocumented. I’d never get to it by myself.

1 Like

Could you please be so kind and elaborate on this?
What exactly do I need to do in my material to get this working?

I’ve just modified Opacity Mask Clip Value that’s located in advanced settings of material properties. It actually does controls this cutout thing for Custom Depth/stencil buffer in translucent shading model.

6 Likes

I would love to know what you put into the custom node to detect what pass you are on as well…
This could greatly improve a lot of the performance issues that Water shaders usually have…

I didn’t do a custom node. It was a **Kalle_H.**I guess, he’s overriding mask with it. But to make the mask fully opaque it’s enough just to change this parameter.

1 Like

Setting the “Opacity Mask Clip Value” in the details panel of the material saved me! As long as the material shows in the world (opacity > 0), it will be rendered in the custom depth buffer. No need for a shadow mesh to render into the custom depth buffer anymore!

2 Likes

Since this thread coming up in Google… As of 5.03 looks like messing with Opacity Clip Mask Value is no longer needed. The field is read-only unless using a Masked material.

If you (1) have “Translucency >> Enable Custom Depth Writes = true” and (2) a value greater than .333 going into your Opacity the object will work with depth buffer highlighting. :smiley:

6 Likes

You saved many lives! Thank you ! :smiley:

1 Like


This is solution for UE 5.4 :wink:

4 Likes

Thank you very much! This also works on 5.3.2