Search Unity

Shader Forge Uinty UI RectMask2D

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by abitofjohn, Mar 9, 2018.

  1. abitofjohn

    abitofjohn

    Joined:
    Nov 6, 2012
    Posts:
    22
    Hi,

    I'm trying to create a UI shader with shader forge. I have it working for the most part but I don't know how to make it work with a RectMask2D. When the UI item with the shader is outside the RectMask2D it still renders.

    I've tried following this guide but it doesn't seem to help. Has anyone had this issue or know of a way to make a custom shader work with RectMask2D?


    Many Thanks

    JT
     
  2. alan_motionlab

    alan_motionlab

    Joined:
    Nov 27, 2014
    Posts:
    89
  3. paradizIsCool

    paradizIsCool

    Joined:
    Jul 10, 2014
    Posts:
    143
    I can explain why, but I cannot check how to do this right now (take a look at the default UI shaders, it may use something like partial culling or alpha culling, I don't remember)

    RectMask2D does not use stencil
    Mask uses stencil


    A RectMask2D: *Only works in the 2D plane *Requires elements on the mask to be coplanar. *Does not require stencil buffer / extra draw calls *Requres fewer draw calls *Culls elements that are outside the mask area.
     
    Last edited: Mar 27, 2018