How to control rendering order for translucent objects if single mesh?


How can you control the rendering order of translucent material if its a single mesh?
My mesh is a character. Its eyes are part of the same mesh, however not welded.

When the material is set to translucent the eyes are not rendered because its rendered behind the face.
Usually when objects are separate its possible to set the z order to establish which gets rendered first.

however this is not possible if its one mesh.

So possible work around would be to split the eyes from the mesh and have it as a separate actor on my skeletal mesh that is attached at runtime.
But this just sounds meh.

Any solutions?

What you need to do in this case is have a separate copy of your mesh with an opaque material that renders into the “custom depth pass” and has “render in main pass” disabled. Then you can look up the custom depth value in your translucent shader, and check vs custom depth and favor pixels that are closer to the custom depth. You will have to calculate opacity manually using some method (ie maybe for the eyeball you could grab the fresnel and use that a bit)? You may need to use some biasing factor to avoid the eye occluding itself. This might get a bit tricky, I have never tried to use it on a character with eyes that are part of the head.

yoh that sounds complicated :stuck_out_tongue:
think i might just settle for the separate mesh workaround instead.

my material skills are mediocre