- Home /
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.
Can someone point me to a simple solution/right direction?
Thanks!
Answer by Demigiant · Sep 28, 2013 at 06:10 PM
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.
Hi, I'm a noob in Unity 3d. Could you please explain / show me a tutorial how did you achieve option 1? Thanks
Take a look here: http://pixelplacement.com/2011/02/15/masking-in-unity/
Hi, for the first solution, would you $$anonymous$$d to provide more details? (A new Unity player here) How to add a separate camera and make a gameobject rendered from it?
Your answer
![](https://koobas.hobune.stream/wayback/20220613114951im_/https://answers.unity.com/themes/thub/images/avi.jpg)