Lit Transparency Depth Pass (From UE3)

“Lit Transparency Depth Pass” seems to be no longer available in UE4. This was supposed to help with hair sorting, as seen here: https://rocket.unrealengine.com/docs/ue4/INT/Engine/Subsystems/Rendering/MaterialsAndTextures/Materials/CreatingHairUsingAlpha/index.html

Incorrect self sorted geometry, most noticable when using A=255:

To give you an idea of the actual shape:

This is definitely a feature we require to continue development in this engine.

Is there an alternative or do you guys plan on adding this feature in again?

The issue here is deffered rendering. It’s really not something that can be easily solved in it.

Best solution would be adding Forward rendering pass, for opacity/translucent objects. Would be nice to have this functionality. The issue is that adding forward path, means essentialy manintaing separate set of shaders and part of rendering engine.

Simply speaking I doubt that sorting these issues is something that we can expect soon, even if it is high on priority list.
Would be cool to hear from Epic nontheless.

This object is however already drawn outside of the Deferred pass (probably what you suggested?) which implies this is already done with Forward shading, all I need is an additional depth pass right before translucensy.

Coming to think of it…I might be able to hack this in using the Custom Depth layer! I will need to render my object twice with two different materials (one opaque for pure depth pass) I’ll give this a try asap.

Hi Tom,

I am glad you found a work around and we appreciate the feedback. I have gone ahead and added a feature request for a lit transparency depth pass. Have a great day!

-Adam

I’ve found a solution / workaround using “Custom Depth”.

Simplified Steps:

  • BP with two meshes.
  • One mesh is the regular transparent mesh you want depth-tested.
  • The other is the same mesh resource, but with opaque material. (You can set the opaque material during Construction)
  • Set the “Render in Main Pass” to false under Rendering for this 2nd mesh. Also change “Render Custom Depth” to true.
  • Now you can perform depth testing in the translucent shader, by “If” comparing the PixelDepth with SceneTexture’CustomDepth’ don’t forget to add a constant to add/substract a depth bias to your PixelDepth!

Original:

With depth-test:

I have two use-cases for this custom depth testing, one is a hologram shader (I’ll post this on the forum soon) the other is a shader that requires proper handling of mixed opaque and translucent material sections. The second requires more complex shading than binary opacity as demonstrated in the attached images, but the data is now available!

One thing that bothers me is that theorically I want to combine this with an outline shader for other objects types, these use the Custom Depth layer as well! Perhaps this could be hacked by sectioning the depth into types (eg. 0-0.25 is for outlines, 0.26-0.50 is for depth tested translucency. This of course requires offsetting the depth for the objects using Depth Bias.

Please let me know if you (Epic) decide to support this natively as in UE3 or if you have a suggestion if multiple features require the Custom Depth!