Search Unity

Stencil Shaders Help

Discussion in 'Shaders' started by DARKHAWX, Aug 25, 2017.

  1. DARKHAWX

    DARKHAWX

    Joined:
    Apr 15, 2017
    Posts:
    15
    So I'm having a bit of a problem getting my head around stencil shaders. Right now I basically want a shader to attach to a plane that will show a completely different "world" behind it. I know stencil buffers can be used to reveal certain objects, however I basically want to replace the entire world. I have made the plane spontaneously appear in front of some objects that have just a standard shader attached to them. I also have some other different objects in the same area that require the stencil shader to appear. I want the plane to basically filter out all the normal objects and then reveal the hidden objects.

    So I know I can make the plane's shader set the stencil buffer to 1 and then have all the hidden objects require a stencil buffer value of 1 to reveal. However I want the other objects to disappear, but I don't want to modify their shaders.

    How can I do this?
     
  2. smosh92

    smosh92

    Joined:
    Jun 28, 2015
    Posts:
    12
    you'd probably want to use a portal effect for this one instead of a shader. basically setup both worlds in a single scene such that the player cant see them directly. only through a window portal. you can make such a portal using cameras and render textures. here's a link to the video if you need a full walkthrough on how to do it:

     
  3. nights007

    nights007

    Joined:
    Aug 12, 2014
    Posts:
    17
    That one is using render texture , very different from what he asked for