Search Unity

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,352
  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,352
    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.
     
  7. bruceweir1

    bruceweir1

    Joined:
    Nov 29, 2017
    Posts:
    15
    Is this still a feature that is missing from ShaderGraph? It would be nice to have access to the stencil buffer values (for reading and writing) if possible.
     
  8. s4lt3d

    s4lt3d

    Joined:
    Nov 21, 2014
    Posts:
    14
    Yes it is still missing and it's surprising that a tool written this long ago doesn't have this basic support.
     
    Genebris and alphdevcode like this.