Search Unity

Alpha Cutout Shadows in Deferred

Discussion in 'Shaders' started by tetriste, Sep 22, 2017.

  1. tetriste

    tetriste

    Joined:
    Mar 29, 2017
    Posts:
    13
    Hello,

    I'm currently working on a deferred pipeline. So far everything works well except that I have a huge difficulty getting alpha cutout shadows to work.

    My current setup :

    I have a uber shader with different options, with a custom vertex shader for displacement and I'm using a surface shader for passing all the info to the rest of the pipeline.

    I tried renaming my alpha cutout properties to _Cutoff and _MainTex (so it fits with the internal depth normal shader), I tried creating my own depth normal shader, nothing seems to change the result. I have an alpha cutout looking mesh, with a whole shadow :/

    I know it would be possible to create a variation of that shader in forward for the specific case we need cutout, but since we may end up having a lot of vegetation, I would like to stay in our pipeline.

    Anyone knows how to handle Alpha Cutout (or Transparent Cutout) for shadows, in deferred?

    Ideally, I would like it even more if I could have my own depth normal shader to work with the deferred pipeline, but it feels like it doesn't change anything :/

    upload_2017-9-22_17-15-37.png
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Looking at a cutout shader in my project, which uses the deferred rendering pipeline...
    Code (CSharp):
    1.     Tags
    2.     {
    3.         "Queue" = "AlphaTest"
    4.         "RenderType" = "TransparentCutout"
    5.         "IgnoreProjector" = "True"
    6.     }
    Code (CSharp):
    1. #pragma surface surf Lambert vertex:vert alphatest:_Cutoff addshadow nometa nolightmap nodynlightmap nodirlightmap
    Notice alphatest and addshadow, see here

    Code (CSharp):
    1. Fallback "Legacy Shaders/Transparent/Cutout/VertexLit"
    These seem to be the things that differ from a regular opaque shader in my project.
     
  3. tetriste

    tetriste

    Joined:
    Mar 29, 2017
    Posts:
    13
    alphatest and addshadow does the trick :D thanks! I was using a custom clip before. I'm surprised that it follows up with my custom "main" texture though, I thought I would've needed to rename all for _MainTex. Anyways, it solves my issue, thanks again :)