Search Unity

3D masks or how to make 3D object transparent/translucent

Discussion in 'General Graphics' started by NotEvenAverage, Oct 9, 2019.

  1. NotEvenAverage

    NotEvenAverage

    Joined:
    Dec 1, 2013
    Posts:
    4
    Hello,

    I have a problem and idea to solve it but if it is possible I will be super happy to hear some suggestions or even solutions on how to make 3D object translucent (like when alpha is set to 0.2 or something close) or fully transparent. I want to use this effect in only one situation (so far). It is an isometric game where your character is in the middle of the screen and whenever a character is behind tree or building I want this object to be translucent so you still know it is there but also allows you to see a character.

    What I tried so far?

    I know that when an object has material that has a color you can set there transparency and it will work but this solution has two problems. First, it doesn't work when an object has texture instead of color. Second, it also makes the shadow disappear or just make it brighter.

    My second solution was to use a shader graph and then make an object dissolve with it or make it transparent. This works as well but there is another problem first I use some assets in my game that don't work with Universal Render Pipeline and right now I don't plan to use this shader graph to anything more than that so I prefer to just find an alternative solution.

    What is my idea?

    Well, it is probably far from perfect approach but I think I can do something like that. I can set up two cameras at exactly the same place and they will move together. Then one camera will see everything and second only things that like character, ground, grass, etc. but not building and trees, and then I would use something like a mask on a screen that can follow character/enemies and will be in shape of a circle. This way I will have trees etc. but parts around characters will have them translucent. But I see few problems here, first: this will make area around character translucent so it includes trees in front of characters (what is great) but also trees behind character (and this isn't great), second if I'm not mistaken it will affect shadows as well at least in this masked area but it is something that I can live with... but still prefer to keep shadows.

    So, guys, can you suggest me something to solve this? Maybe my solution is good but I need to read about something so it can solve these issues or maybe you have ready solutions for this or something that you never did but know that can help. I am willing to learn new things so let me know about everything you think can help.