Search Unity

URP - 2D Renderer grab pass and stencil

Discussion in '2D' started by mbitzos, Apr 15, 2020.

  1. mbitzos

    mbitzos

    Joined:
    Jun 8, 2018
    Posts:
    17
    I just recently upgraded to the new 2019.3 URP + 2D renderer pipeline so I can get those sweet new 2D lights.

    The thing is now I am in the process of upgrading all my old shaders. some of these shaders utilized the grab pass and stencil but the problem is I can't seem to find anywhere on line that tells me how to access this stuff now through Shader Graph (at least specifically for the URP and 2D renderer).

    For Grab pass the best i got was that in LWRP (I guess now renamed to URP) you could access this as a texture "_CameraOpaqueTexture" in your shader (https://docs.unity3d.com/Packages/com.unity.render-pipelines.lightweight@6.7/manual/lwrp-asset.html). But i'm not entirely sure if this is working correctly as I have included the property "_CameraOpaqueTexture" Texture2D as a property and have connected it to a sample node and have simply shoved that into the color node of the Sprite Lit Master but it shows only white (which makes me thing its not actually being included)

    Additionally for accessing the Stencil I also couldnt seem to find anything relating to that, but on the 2D renderer theres an option to "Use Depth/Stencil Buffer" which is for enabling the sprite mask feature. So I'm thinking theres gotta be a way for me to access the stencil since thats how sprite mask works.

    Any help is appreciated!
     
  2. thatnoobles

    thatnoobles

    Joined:
    Jun 22, 2018
    Posts:
    6
    Sorry for bumping an old-ish thread but I'd like to know this too.
     
  3. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    We are working on a grab pass replacement for the 2D Renderer, and it should arrive in URP v11.

    Stencil in Shader Graph isn't currently supported, but the Shader Graph team has received a lot of requirements for it and I'm sure they will do something about it soon.
     
  4. thatnoobles

    thatnoobles

    Joined:
    Jun 22, 2018
    Posts:
    6
    Alright, thank you! I was more concerned about grab pass rather than stencil, but I'm glad to hear it's coming soon.
     
  5. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I tried the stencil using Amplify Shader Editor and it "seems" to work, but I have question about it especially to do with Sprite Mask. I believe Sprite Mask make heavy use of stencil internally, so I wonder if custom usage of stencil buffer will mess with Sprite Mask.?
     
  6. aegis123321

    aegis123321

    Joined:
    Jul 5, 2015
    Posts:
    71
    I'm so glad to hear this feature is coming! But I'm also worried if it will not be a good alternative approach. I hope that you guys can show the idea of this approach, so I can trust and wait for this feature without any doubt.
     
    castor76 likes this.
  7. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Indeed. We need more info about how they may / will work..