1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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:
    57
    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.