Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Stencil properties in UI shader, using Shader Forge

Discussion in 'UGUI & TextMesh Pro' started by Flarup, Sep 21, 2015.

  1. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    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:
    464
    Flarup likes this.
  3. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    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:
    218
    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
     
    Teejay5 and Izzy2000 like this.