Search Unity

Stencil properties in UI shader, using Shader Forge

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Flarup, Sep 21, 2015.

  1. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    122
    Hello,


    I have a custom made shader (made in Shader Forge) which I would like to use as a part of my UI for rendering some images inside a Scroll View. However, when I try to use this shader for UI rendering, then I get the following warning from Unity:

    Material MyMaterialName doesn't have stencil properties

    This warning is quite expected, since this shader previously just was used for rendering meshes ingame, and not for rendering UI, so I haven't implemented any stencil properties support in the shader. The result is that UI images using this shader are still rendered when they are outside of the visible area of the Scroll View. This is also quite expected :)

    My questions are:

    1) Is there an easy way to get a Shader Forge shader work well with Unity UI? (enabling "Stencil Buffer" under "Blending" doesn't suffice)

    2) If the answer is "no" to question 1, then what would you recommend for Unity UI shaders - make your custom UI shaders without Shader Forge, or something else?


    Thank you very much in advance for your help.


    Kind regards,
    Uffe Flarup
     
  2. rorakin3

    rorakin3

    Joined:
    Jan 2, 2013
    Posts:
    455
    Flarup likes this.
  3. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    122
    Thanks for your reply. I (unfortunately) also ended up concluding that UI shaders and Shader Forge dont play well together.
     
  4. Michiel-Frankfort

    Michiel-Frankfort

    Joined:
    Sep 7, 2014
    Posts:
    39
    Hi,

    Just a little visual update for 5.4.1 to get a Shaderforge-shader working with stencil UI Mask component. I hope it helps...
    Michiel Frankfort - Shaderforge UI masking.jpg
     
    Izzy2000 likes this.