Search Unity

Feature Request Turn off "Receive shadows" on custom PBR graph [LWRP]

Discussion in 'Shader Graph' started by WendelinReich, Apr 8, 2019.

  1. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    228
    Hi, standard LWRP "Lit" and "Simple Lit" shaders have a checkmark for turning off "Receive shadows" (see below. There needs to be something similar for custom lit graphs.

    upload_2019-4-8_11-3-51.png

    Also, as of 2019.1 (I'm using b8), the MeshRenderer component doesn't have a checkbox for "Receive shadows" anymore, so right now (as a mobile dev) I'm pretty stuck...

    upload_2019-4-8_11-2-44.png
     
    patrickdown likes this.
  2. Kink3d

    Kink3d

    Joined:
    Nov 16, 2015
    Posts:
    45
    Hi,

    This has been on our radar for some time now. Hopefully we will get to implementing this soon (it was/is dependent on some refactor work that is currently going on).
     
    patrickdown and WendelinReich like this.
  3. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    228
    That's good to know. It would be great if you could treat this as a bug or somehow prioritize it, because it makes shadows on performance-sensitive devices unusable ATM (turning off shadows altogether seems to be the only way to avoid the performance penalty of having too many unwanted shadow receivers)...
     
    pauliusuza likes this.
  4. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    228
    Hi @Kink3d, any ETA on this one?
     
    Miscellaneous and ZhavShaw like this.
  5. Ehredt

    Ehredt

    Joined:
    Jun 20, 2018
    Posts:
    79
    Hi I'm also very interested in this but especially for the HDRP! I have a feature in my current project that absolutely depends on it (especially implementable for only front- or back-facing, so turning it off on the mesh renderer won't help). I don't really speak HLSL so I'd rather not have to write a custom node for it if it's going to be on the horizon within the next couple months -- @Kink3d is there an ETA? Thanks!
     
    WendelinReich likes this.
  6. jessemoreland0

    jessemoreland0

    Joined:
    Apr 10, 2018
    Posts:
    8
    I also need this functionality.
     
    Miscellaneous and WendelinReich like this.
  7. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    129
    I need it too.
     
    Miscellaneous and WendelinReich like this.
  8. Jeffrey-Lee

    Jeffrey-Lee

    Joined:
    Nov 8, 2012
    Posts:
    2
  9. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    228
    I think this thread should get a response from a Unity employee...
     
    Miscellaneous likes this.
  10. jensen_305

    jensen_305

    Joined:
    May 15, 2018
    Posts:
    27
    Also looking for this feature.

    Since this comes up on Google Search and others may want to know how to turn receive shadows off as of 9/19/2019.

    Work around:
    Open Shader in Shader Graph. Right click the master node and select view code. Copy the code and in Unity create new shader of the standard type so it opens in an editor. Open the file and paste the code in and add the following line near the top, you'll see other #pragma stuff where it should go.

    Code (CSharp):
    1. #pragma shader_feature _RECEIVE_SHADOWS_OFF
    Save the shader file. In Unity select the new shader right click and create a new material from it. This material will no longer receive shadows.

    Note:
    Only downside is any change to the Shader Graph and you have to redo this.
     
    Last edited: Sep 20, 2019
  11. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    985

    > #pragma shader_feature _RECEIVE_SHADOWS_OFF
    -- this doesn't seem to be working for me in 2019.3 beta.
    I'm shocked this option is missing. I'm making a simple ground fog shader for VR and this is the only missing thing.
     
  12. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    228
    Does anyone know whom at Unity to make aware of this thread? Then please do. (Not getting a response from @Kink3d). This seems like such a blatant omission....
     
  13. LandonTownsend

    LandonTownsend

    Unity Technologies

    Joined:
    Aug 21, 2019
    Posts:
    35
    You can do this with the new "keywords" feature added in 7.1.1. Unfortunately we ran up against some engine limitations when developing keywords that makes doing this a bit hard to figure out, but it's still possible.

    Step 1:
    Add the following keyword to your shadergraph. Make sure the options are the same.
    upload_2019-9-27_11-13-41.png
    Step 2:
    Make a material with the shadergraph, and select the material in the inspector.
    Click the three dots in the upper right corner of the inspector and choose "debug".
    upload_2019-9-27_11-27-30.png
    Add your keyword to the "Shader Keywords" box:
    upload_2019-9-27_11-28-14.png

    And you're done.
    upload_2019-9-27_11-29-0.png

    upload_2019-9-27_11-29-13.png
     
    Cylau, zalogic, adamgolden and 6 others like this.
  14. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    985
    @LandonTownsend What version of Unity should be used with this ideally? Is the beta good enough or alpha preferred?
     
  15. LandonTownsend

    LandonTownsend

    Unity Technologies

    Joined:
    Aug 21, 2019
    Posts:
    35
    I did this on version 2019.3.0b4, as long as you at least have that version it should work. Remember to back up your project before upgrading.
     
  16. ClayChi

    ClayChi

    Joined:
    Mar 30, 2018
    Posts:
    7
    I tried using keywords.
    It looks like I can't make unlit shader to receive shadows with _RECEIVE_SHADOWS_ON / OFF keywords.
    But it works for PBR to not receive shadows.
     
    Last edited: Nov 24, 2019
  17. theonenr

    theonenr

    Joined:
    Aug 4, 2014
    Posts:
    19
    Thanks, works fine.
    But i wana receive the lighting settings fog in exponential mode too. I tried with the same steps and added FOG_EXP keyword as boolean from the global keywords in the shadergraph and in material keywords, but it does not work :(
    What am I doing wrong?
    shader_prob1.png
    shader_prob2.png
     
  18. Ehredt

    Ehredt

    Joined:
    Jun 20, 2018
    Posts:
    79
    @LandonTownsend Adding _RECEIVE_SHADOWS_OFF, or any keyword, to a Shader Graph breaks subsurface scattering -- it's as though subsurface scattering isn't enabled at all. Is this as expected? Thanks!

    (I'm using 2019.3.0f1, HDRP version 7.1.6)
     
  19. jp_xsi4life

    jp_xsi4life

    Joined:
    Jan 2, 2020
    Posts:
    7
    @LandonTownsend Any update on this for 2020.1? Is the debug / keywords workaround the only way to do this?
     
  20. Dorodo

    Dorodo

    Joined:
    Mar 8, 2015
    Posts:
    44
    Any updates on this? The workaround works but is pretty bad to deal with on a pipeline basis.
     
    WendelinReich likes this.
  21. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Also wondering if there is any update on this? Workaround is not an option for us, because of generating too many variants by adding additional keywords.
     
    ynaoto likes this.
  22. ynaoto

    ynaoto

    Joined:
    Mar 26, 2016
    Posts:
    21
  23. instruct9r

    instruct9r

    Joined:
    Aug 1, 2012
    Posts:
    148
  24. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    97
    Two years later and still the workaround is the only solution available? This feels like a very essential feature, I hope there will be a better solution soon...

    Edit: I thought this wouldnt work, but it turned out I added a "Enum Keyword" instead of a boolean Keyword. After fixing my mistake it did work with Unity 2020.2.0f1
     

    Attached Files:

    Last edited: Apr 14, 2021
    instruct9r likes this.
  25. instruct9r

    instruct9r

    Joined:
    Aug 1, 2012
    Posts:
    148
    m yeah i am using the latest 2020 LTS and i tried the Keyword trick, but it doesn't work...
     
    Fressbrett likes this.
  26. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    97
    Have a look at my last comment, I thought it didnt work as well, but after switching from an enum keyword to a boolean keywork it actually worked!
     
    instruct9r likes this.
  27. Marxy37

    Marxy37

    Joined:
    Jan 17, 2020
    Posts:
    3
    Make sure that both name and the reference and the reference of the keyword is _RECEIVE_SHADOWS_OFF. I've spent like 20 mins to trying to figure it out what i did wrong, just because unity had set the reference to a different name.
     

    Attached Files:

    instruct9r likes this.
  28. Monsterwald

    Monsterwald

    Joined:
    Jan 19, 2020
    Posts:
    68
    and still no solution.... keyword does not work either :/ and yes its set to boolean and name + reference are _RECEIVE_SHADOWS_OFF
     
  29. jensVrag

    jensVrag

    Joined:
    Aug 9, 2019
    Posts:
    13

    Thank you, this worked for me. Can I ask, what other built-in keywords are there we could use in similar fashion? Thinking of Zwrite and stenciling etc..
    Cheers!
     
    Last edited: Sep 29, 2021