1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  3. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  4. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  5. Unity 5.5 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  7. Unity 5.6 beta is now available for download.
    Dismiss Notice

Stencil buffer overlays

Discussion in 'Shaders' started by Everest1986, Mar 20, 2017.

  1. Everest1986

    Everest1986

    Joined:
    Nov 21, 2015
    Posts:
    2
    Hi all,

    Could somebody help me. I try to understand stencil buffer. I have put in shader something like this:

    For moving object:
    Properties
    {
    _Ref("Layer", int) = 0
    _Comp("ComparitionEnum", Int) = 6
    }
    Stencil
    {
    Ref [_Ref]
    Comp [_Comp] //notequal
    Pass Keep
    }

    For walls:
    Properties
    {
    _Ref("Layer", int) = 0
    }
    Stencil
    {
    Ref [_Ref]
    Comp Always
    Pass replace
    }

    Unfortunately stencils sometimes are overlay and I have situation like below:

    [​IMG]
    Somebody know how to achieve That with stencils.
     
  2. faren

    faren

    Joined:
    Sep 10, 2015
    Posts:
    51
    You must set the geometry queue of the moving objects after the wall. It's just a tag "Queue"="Geometry+1"
     
  3. Everest1986

    Everest1986

    Joined:
    Nov 21, 2015
    Posts:
    2
    Ok, but then it cause another issue. I have some objects that I would like to be rendered under moving object. This all is in 2D. Please find picture below:
    [​IMG]
    I want that object with higher Y position will be under moving object.