Unable to render Custom Depth with translucent material applied

I’m unable to see the mesh rendered into Custom Depth while I have a translucent material applied. This does work with any opaque material.

Nasty workaround is to create a blueprint with second copy of mesh (gets works when animation gets involved) that is only drawn into custom depth and not main pass and has a simple opaque material applied.

3 Likes

Is this intended behaviour? It also stops the object showing up the scene depth texture, it would be nice if it could be toggled on a per object basis. This comment seems to suggest is intended behaviour but sadly doesn’t elaborate on how to change it.

You will need a separate mesh with an opaque material currently. You can set that copy to not render in main pass and to render only in custom depth.

You will need a separate mesh with an opaque material currently. You can set that copy to not render in main pass and to render only in custom depth.

There is a property called “Allow Custom Depth Writes” within “Translucency”. Set it to true and it will compile additional shaders to enable custom depth.

I hope this helps.

10 Likes

Thanks, that works for me.

Perfect!! Thanks!!

It has not been mentioned before, but I want to point out that you need to set the “Opacity Mask Clip Value” of the Material properties to something you can work with. For example. Currently in UE4 4.20, this value is set to 0.33. If you use the technique above with a translucent material set to 0.32 in opacity, the post processing material will not show.

In my case, i need to show only the outline of a completely transparent material, so I had to set this value to 0.0.

5 Likes

Yes, especially at 4.22.3

you’re my hero!

1 Like

Since this thread coming up in Google… As of engine version 5.03 looks like messing with the “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, then the object will work with depth buffer highlighting. :sunglasses:

1 Like

something close to this topic is when translucent mat is shown, scene depth is wrong from the texture sampler. “Allow Custom Depth Writes” dosent help this.
Any idea about how to get the right scene depth while tranparent object is on?