Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Transparent But Behaves like Opaque

Discussion in 'Shaders' started by SMD-Indomitable, Dec 15, 2017.

  1. SMD-Indomitable

    SMD-Indomitable

    Joined:
    Mar 21, 2016
    Posts:
    9
    Hi Everyone,

    I need your help regarding Shaders, I am completely new to Shaders, but I am going to learn it soon. Can someone enlighten me on how I can make a shader that looks transparent but behave like opaque. I just need to understand the concept on how I can achieve it, so I can start my researching.

    I am actually a custom content creator for a game. Cant be considered a modder because we have no access to writing code for the game. Hence, I am trying to write a Shader to achieve that behaviour without adding scripts. Basically, I cant touch the player model of the game, hence I cant simply change its alpha. I can only add material to the armour I am making, hence I have the shader idea. Basically what this shader would do, is to cover up the player model even if the armor looks transparent.

    Thanks for your time, hope to hear some suggestion soon.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,256
    You want the armor to be transparent such that it shows the world, but not the character model?

    That will require far more than a shader on the armor. It requires explicit control over the order in which the environment, armor and character get rendered. What you want is a surprisingly difficult thing to get right and requires multiple stencil and/or depth only rendering passes. Doing this all purely in a shader for the armor is simply not possible.
     
  3. SMD-Indomitable

    SMD-Indomitable

    Joined:
    Mar 21, 2016
    Posts:
    9
    Thanks for the quick reply :D. Yes, I want it to show the world, but covers the player. It is made as a stealth armour. Is there any other ways I can achieve it? As long as I can get the stealth effect with just a shader
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,256
    No.

    It requires more control than a shader on a single part is capable of.

    The most basic way I can think of to do this would be by using a “depth pre pass” alpha shader on both the character and the armor. If you’re lucky Unity will run the depth prepass on both meshes before the second two passes, but they you do need to use the exact same shader on both parts.
     
  5. SMD-Indomitable

    SMD-Indomitable

    Joined:
    Mar 21, 2016
    Posts:
    9
    Ah, I see. Since I cant change the material on the character model, this is really impossible then. Thanks alot for the reply, really appreciate it :D