I have a situation where I want to be able to render parts of my scene as semi-transparent. More specifically I want the player character to be rendered as semi-transparent if certain objects gets too close.
I’ve tried achieving this by having one camera only rendering the player character and one camera for everything else. The problem is that (to my knowledge) it is not possible to change the transparency of a camera.
Then I tried rendering to a RenderTexture on the camera rendering the player character, using Depth Only as clear flags and then render this texture to the main camera, using GUI.DrawTexture. The problem here is that every “empty” pixel from the player character cam will simply be black on the render texture and thus overwrite everything on the main camera. Furthermore, I don’t see how I can change the transparency of a RenderTexture, to achieve the effect I want.
Does anyone have a solution for this? I don’t want to change the texture of the player character to become more or less transparent, since that gives weird results (looks like you are looking into the character), so I’m really hoping it can be solved with cameras somehow.