Proper smooth fading material?

Hey, I’m trying to make a smooth fade out material.

Basically when the player character passes behind an object, its material should gradually fade to 10% transparency or so.

Issues:

A. when using a masked material blend mode with AA dithering, anything moving behind the object gets lots of motion blur. not ideal since what I want with this effect is to be able to see properly what is behind this material.

B. when using a translucent blend mode with opacity, the object’s surface doesn’t become transparent as a whole, it becomes glassy, and you can see through all the elements of it, like this:

C. when using an additive blend mode material with custom depth pass enabled on the mesh (so you can compare the pixel depth with the custom depth mask to make only the surface of the material invisible), you can never make the material fully opaque since it’s additive. it’s always somewhat transparent. (i tried it like this:)

So I ran out of ideas. anyone can think of something?

What about dispersing material? is it a viable option for you?

Not sure if this will help, but you can fix Option B by using the custom depth buffer like you did for Option C (though I’ll admit I didn’t quite understand what you were attempting there).

Here’s a screenshot of my simple test:

It’s just two cubes in the same actor. As you can see, they do not see through all elements anymore.

Here is the material. You can use Lighting Model = “Surface ForwardShading” in the material properties for the best looking results though it’s the slowest. You’ll need to set your mesh to draw into the depth buffer as well as enable depth writes on your material.

You might want to switch to an opaque surface when displayed normally. Setting the opacity to 100% won’t display the same as an opaque material.

Hey, thanks for replying

But I don’t think it quite works as intended. Here’s my test, 3 different materials with opacity set to 0,5 so it shows better.

(I used mannequins because you can really see the ball joints through the mesh when the effect isn’t working as intended, but the transparency effect will be added to parts of the level that are in front of the player character. To clarify, what I want is simply to turn any meshes that end up between the player character and the camera transparent, so they don’t occlude the character. The issue is that I want that masked but not translucent look like you’ll see below)

left one’s material: (blend mode: translucent)

mid one material: (blend mode: masked)

right one material: (blend mode: translucent) like your suggestion

It’s noticeable how different the middle one looks, and that’s the look I want. the problem is the motion blur that happens whenever anything such as the player character moves behind the masked transparent mesh.

Sadly not in this case, no

Ah, you’re right. I tried it on a skeletal mesh and it didn’t look good. I fixed it by duplicating the mesh and assigning it an opaque material. Color doesn’t matter. On the mesh component, turn off cast shadows, turn off Render in Main Pass, turn off Render in Depth Pass and turn on Render CustomDepth Pass.

What this will do is render a proper self occluding version of the mesh in the main pass into the custom depth buffer. This allows us to correctly draw the transparent mesh. Note that this will occlude any transparent objects behind this mesh that also uses the custom depth buffer.

As for the AA dithering version, I think the motion blur can be removed by using the same technique. I think the messy blur is because the motion vectors are only written on every second pixel. So if you add a duplicate like above, it might overwrite the motion vectors. If you don’t want to write to the custom depth, it might be possible to use a translucent material with opacity of 0 and enable writing the motion vectors. Not sure if this would work, but might be worth a try.