Download

Depth Tested Transparent material

Hello, im working on some complex shaders for a VR project, and one of them is a transparent “blob” thing. Of course, im using transparent material model, and a bunch of nodes to control the opacity/refraction/etc. It works very well, but it has a problem.

Transparent shaders are not depth tested, and that means that if my object is not convex, it can draw on itself. Im not asking about ordered transparency or anything of the like, just if there is a way to do depth testing on it.

Right now i have a duplicate mesh wich is the exact same, and it is just a default unlit material with Custom Depth on and visibility off, so it draws to the custom depth and then i can test using that in my custom transparent material.

Is there a way to do that in a more “streamlined” way? If i was doing that in my own engine, it would be just enabling depth buffer test, but in UE4 transparent materials have no depth and only opaque ones do. A masked translucent material is out of the question, the temporal antialiasing transparency using dithering wont work becouse its on VR and we disable temporal antialiasing.