Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Any way to set Stencil buffer in Shader Graph?

Discussion in 'Shaders' started by JamesThornton, May 8, 2018.

  1. JamesThornton

    JamesThornton

    Joined:
    Jun 26, 2015
    Posts:
    52
    Hello!

    I'd like to render elements of a scene through a limited window.

    I was following a dimension portal tutorial to learn how stencil buffers work. However, I don't see any access to stencil in Shader Graph like there was in Shader Forge.

    Is there any way to add the Stencil code section?

    Thanks for any help understanding!
     
  2. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    Did you find a solution to this? Was trying the same atm :D
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
  4. JamesThornton

    JamesThornton

    Joined:
    Jun 26, 2015
    Posts:
    52
    @Desoxi Actually it motivated me to learn how to write basic shaders, and it was totally worth it. It's well documented thankfully, with tons of examples online. Wasn't as difficult as I thought, but my needs were pretty basic.

    You can also download the built-in Unity shaders from the archive page. The standard shader looks pretty complex, but it's there to reverse engineer and tinker with if I ever need to.

    It's worth noting this was after I switched back to the built-in renderer. Writing shaders for LWRP probably has different requirements and less documentation.
     
  5. EricLowry

    EricLowry

    Joined:
    Apr 12, 2015
    Posts:
    17
    Well, I'm in the exact same situation here, trying to use the ShaderGraph for UI.Image objects, and it's a mess.
    My issue is that I'm having a REALLY hard time figuring out how to use the "old" shader language, especially since I need to do some pretty fancy math in some of my shaders...

    If you have a good tutrial, that'd be great, but if there is a way to get ShaderGraph to work with UI.Image objects, that'd be much better ;)
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    See the thread I linked above. However, right now Shader Graph is not intended for use with UI components and there isn't any way to get them to work nicely together without converting the Shader Graph to a vertex fragment shader and modifying it by hand.