Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Matte Shader (Only Shadows) in HDRP

Discussion in 'High Definition Render Pipeline' started by herrenderschoepfung, Sep 6, 2019.

  1. herrenderschoepfung

    herrenderschoepfung

    Joined:
    Nov 18, 2016
    Posts:
    5
    Hi everyone,

    I'm using HDRP for my current project and I need to cast a shadow on a transparent plane. So far I found quite a bunch of tutorials on how to do that using regular Unity shaders in SRP, but none for HDRP (preferably using default shaders or Shader Graph).

    Thanks for your help!
     
  2. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    551
    I think semi-transparent shadows are for Realtime Raytracing only. That's the only way I know that works in Unity out of the box.
     
    chap-unity likes this.
  3. max_at_newgameplus

    max_at_newgameplus

    Joined:
    Apr 24, 2016
    Posts:
    34
    @Bordeaux_Fox what do you mean exactly? Like you can make a Shadow Matte shader (transparent shader that receives only shadow info) for RTX shadows in HDRP? How would you go about doing that?
    I realized last night that Unity has an option for making a shadow matte in the Unlit shader graph, but when I played around with it it had fairly bad results with RTX shadows. Have you had success making an RTX shadow matte shader?
     
    Last edited: Feb 14, 2020
  4. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    551
    Last edited: Feb 15, 2020
  5. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    796
    Hi,
    maybe there is confusion regarding name.

    For rasterization we support:
    - opaque shadow from opaque and transparent
    - shadow matte (with unlit shader, those are shadow only without lighting from light)

    For raytracing we support:
    - Colored or not directional shadow
    - Monochromatic spot / point shadow (what is call semi-transparent in the documentation)
     
  6. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    390
    I think what you are looking for is an unlit master node with "Shadow Matte" enabled : upload_2020-2-18_14-55-14.png

    Once you've set the material to transparent and 0 opacity, you will have this : upload_2020-2-18_14-55-56.png
     
    keeponshading likes this.
  7. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    678
    Hi. In Blender EEVEE is use this method because on the ground there is mostly reflection involved.



    Is there an easy to do this in a SG as extension of the method described before?
    It s a little limitating to have the Shadow Matte only in the Unlit Master.
     
  8. AntiloopStudio

    AntiloopStudio

    Joined:
    Jul 14, 2013
    Posts:
    12
    @Remy_Unity
    I have tried to copy your shader but with no luck, for me there are no shadows appearing :(

    See the screen shots below for extra information:

    Here is my shader graph (copy of what you did):


    Here is my material:


    This is the material applied to the mesh (probably redundant):


    And here is the result, no shadow sadly..


    How can i get this to work?

    Side question also my properties are not showing up in the inspector.

    Extra information:

    Using unity version 2019.3.3f1
    Using HDRP version 7.1.8

    If more information is required pls let me know so i can add it :)
     
  9. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    390
    If the properties are not appearing in the inspector, I suspect that there is a compilation issue on the shader.
    At this point it's getting hard to guess what is the root cause only looking at your screens, and it would be better to share your project.
     
  10. AntiloopStudio

    AntiloopStudio

    Joined:
    Jul 14, 2013
    Posts:
    12
    Hi sadly I cant share my project..
    But could you give me some pointers on where to look? Maybe player settings?
    Or could i just share the shader, or some other specific file?
     
  11. ReMix3D

    ReMix3D

    Joined:
    Sep 9, 2012
    Posts:
    14
    If you could isolate the issue in a specific scene with non protected assets, like the susane head and an open source HDRI, that would be great, to share it safely.
    If you can't, there is maybe the option to PM me the project.
     
  12. AntiloopStudio

    AntiloopStudio

    Joined:
    Jul 14, 2013
    Posts:
    12
    Thanks for the tip. See the files below:
    (If any other file is required let me know so i can also share those)
     

    Attached Files:

  13. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    390
    I think your floor plane is in a layer that is not active in the camera culling mask.
    When I looked at it, the plane's layer was set to
    "             "
    , meaning it was using a layer that I did not define in my project.
    Once I moved it to "default", it showed up.
     
  14. AntiloopStudio

    AntiloopStudio

    Joined:
    Jul 14, 2013
    Posts:
    12
    Yeah you'r right that made the floor appear. But In gray without transparancy or shadows. How do i make sure it is transparent with shadows?

    EDIT @Remy_Unity Did you see shadows and transparency?
     
    Last edited: Mar 13, 2020
  15. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    390
    In the example scene you provided :
    • The light was not emitting shadows
    • The master node didn't have shadow mate enabled
    • The alpha of the master node was still 1. Set it to 0 so it can be fully transparent (except shadows)
    Once those steps are fixed, you should have this :
    upload_2020-3-17_13-4-47.png
     
  16. AntiloopStudio

    AntiloopStudio

    Joined:
    Jul 14, 2013
    Posts:
    12
    Awesome, it turned out the light was not emitting shadows... Thank you
     
  17. bobthenob

    bobthenob

    Joined:
    Sep 2, 2013
    Posts:
    22
    cheers this helped me out
     
unityunity