1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. 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
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. 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

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:
    55
    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.