How to gradually Hide / Mask Out a Mesh from top to bottom? Opacity Mask rotates around the mesh wrongly

Scenario

Moving mesh that when it reaches a certain point or collides with a specified thing, it starts disappearing / being masked out, from the collision point to the remaining of the mesh.

If the mesh gets out of the collision zone, the hidden parts re-appear.

For example, in this image, for as long as I move the mesh after the green line, it gets hidden there. In red we already have a part of it hidden:

My broken solution with Opacity Mask

With a Masked Material, by controlling the Opacity Mask, I get strange masking where it doesn’t happen from one point to another, the masks “rotates” around the mesh, as you can see:

The material:


Solution?

  • Any way of doing the intended behavior? I was so close with the Opacity Mask.
  • Any way of achieving is ok with me: having hidden meshes, post process, materials, C++, etc.

Thanks

Simple. Just watch this vid 364 times :slight_smile:

Seriously, the answer is in there…

2 Likes

Thanks a lot! That’s magical. Works perfectly.

For those coming to this post in search of a solution, I posted it as a Snippet: Object Space Gradient Shader (Make Objects Disappear Gradually, etc) | Unreal engine Code Snippet

3 Likes

This does not work anymore as the “ObjectLocalBounds” misc node does not exist in Newer versions of UE5. They’ve replaced it with a vector node but it does not work the same. No one cares that the node doesnt exist anymore and I cannot find a single work around for the life of me.

I think it should work if you just use the ‘extents’ pin.