Search Unity

Depth mask shader, how to?

Discussion in 'Shaders' started by Scoppio, May 4, 2011.

  1. Scoppio

    Scoppio

    Joined:
    Feb 21, 2011
    Posts:
    46
    I'm looking for a Depth mask shader so I can make a hole in a wall (the depth shader) and see what is in another part of the scenario using a second cam.

    Any ideas? (I tried the search box, but no clue at all)
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Stop using the box. It's worthless. Go to the actual search page. The Unify wiki has a documented example of it, and that's accessible by a more universal search.

    Anyway, if this is for your portal, that's not exactly the right solution, although that's where I learned the concept. Alter the Shader to renderer before all the other geometry, instead.

    Code (csharp):
    1. Shader "Clear Portal" {
    2.  
    3. SubShader {
    4.     Tags {Queue = Background}
    5.     Pass {ColorMask 0}
    6. }
    7.  
    8. }
    If you have two cameras, that's an easy enough solution for a single portal which cannot be seen through itself. My method has been to use a shader that blends a funky animated pattern with the earlier-rendered camera, instead of being clear. Then, when I see the portal through itself, I just use a solid texture - the "funky animated pattern" by itself.
     
    Last edited: May 4, 2011
  3. Scoppio

    Scoppio

    Joined:
    Feb 21, 2011
    Posts:
    46
    Thanks Jessy.

    I'll now try to use the shader script thing, never tried it myself (waas always afraid of touching the sahders and do something so bad that my walls had fur and the floor was all spiky)
     
  4. Scoppio

    Scoppio

    Joined:
    Feb 21, 2011
    Posts:
    46
    It worked pretty well, but what happens if I have two portals?

    I'd like to play with the depths here, do you think its easy or possible? I mean... one of my shaders will show the "depth 1" and the other will show "depth 2". basically.
     
  5. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
  6. Scoppio

    Scoppio

    Joined:
    Feb 21, 2011
    Posts:
    46
    Actually my college have unity pro so I don't have to buy it :D