Partially hide object based on position

Hey,

I have a texture, which is used in a plane (using Unlit/Transparent shadder).
I want to make the texture/object partially invisible, based on position 20 in the x axis.
So, everything beyond position 20 should be hidden, when the rest should be visible.

15918-image.png

Can someone point me to a simple solution/right direction?

Thanks!

Uhm, there are 2 ways of doing this that come to my mind:

EASIEST) If you could make that object be rendered from a separate camera, you could place a quad with a depth mask shader after that position, so it would hide what gets under it.

PAIN IN THE A**) Calculate the texture-based coordinates of that point, and whenever the object goes beyond that point, paint transparent pixels over that portion of the texture. Repaint the original pixels when it moves back. Wouldn’t work if the texture is not clamped though.