Search Unity

URP lit shader will not receive shadows while transparency is enabled

Discussion in 'Universal Render Pipeline' started by Centripetal, Dec 8, 2019.

  1. Centripetal

    Centripetal

    Joined:
    May 31, 2013
    Posts:
    96
    I've noticed that the LWRP/URP lit shader (or any other URP shader) will not receive shadows while the transparency is enabled. Is there a workaround for this? Or maybe some kind of shadow catcher material? Maybe I should go back to the default RP and try its mobile shaders.
     
  2. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    162
  3. Centripetal

    Centripetal

    Joined:
    May 31, 2013
    Posts:
    96
    Thanks for the information.
     
  4. Matze_MP

    Matze_MP

    Joined:
    Dec 4, 2018
    Posts:
    37
    Hi, got URP 7.1.8 released 22.January. Where can i find the toggle that is mentioned in the github comments?
     
  5. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    162
    Hey,
    7.1.8 was a minor update to URP and the changes made in my PR were quite significant so this fix was unfortunately not able to be part of that update.

    It will however be in the 7.2 version that's due to release in approx 2 weeks.
     
    zeiksz likes this.
  6. GVUnity

    GVUnity

    Joined:
    May 16, 2018
    Posts:
    5
    @ElvarOrnUnnthorsson Do you have a link to the ticket for this issue?
    I'm working on a project that will need shadows on a transparent surfaces using the URP.

    Sorry, I just noticed your link in your previous post.
     
  7. tylerwongj

    tylerwongj

    Joined:
    Mar 20, 2018
    Posts:
    3
    @Elvar_Orn I'm now with URP 7.2.1. Do shadows still not work on Lit shader with Surface Type: Transparency? I have "Receive Shadows" checked.

    @GVUnity were you able to see shadows?
     
  8. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    If you look in FrameDebugger, can you see a pass that is rendering objects to a shadowmap? (before opaques).
    Do you have "transparents receive shadows" in the renderer asset? It is enabled by default.
    Is you light set to realtime and it has "cast shadows" option enabled?
    Do you have realtime shadows option enabled in your pipeline asset?
     
  9. davisadam10

    davisadam10

    Joined:
    Oct 22, 2016
    Posts:
    3
    Having the same issue as above with 2019.3.4f1 & URP 7.2.1, no shadows on lit transparent shaded objects.

    Simple scene with a stack of objects in Y

    spot light shining down Y at the top
    cube
    transparent plane
    opaque plane at the bottom

    Shadow on the opaque bottom plane of the cube, but nothing on the transparent plane at all.

    In answer to the questions below

    In the frame debugger, yes I do see a pass rendering to a shadow map, can see the shadow on the opaque plane at the bottom of the stack but nothing on the transparent plane

    I do have "transparents receive shadows" turned on, on the material

    My spot light is set to realtime

    Light does not seem to have a "cast shadows" option, however given I am seeing my soft shadows on the bottom opaque plane, Im going to assume this is correctly setup.

    Similarly cant see a "realtime shadows" option in the pipeline asset, there are options for "Cast Shadows" which are turned on, and again I am seeing shadows on the opaque plane.

    Am I missing something silly?
     
    zeiksz likes this.
  10. zeiksz

    zeiksz

    Joined:
    Mar 10, 2019
    Posts:
    10
    2019.3.7f1 URP 7.3.1 still not working properly.

     
    UserNobody likes this.
  11. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    613
    I am using URP 7.2.1 and, you guessed it, for me the "Transparent Receive Shadows" is also not working

    ... for the STANDARD URP materials. However, I noticed that my shader graph material works just fine. Threw that sunofa on my other objects and sure enough my transparent objects had shadows.

    It is, of course, annoying and unintuitive to recreate (and test!) a couple of different shaders, but I hope this at least helps anyone who finds this thread.

    UPDATE:
    In fact, here is a recreation of the Simple Lit shader to get you started.
     

    Attached Files:

    Last edited: Apr 8, 2020
    zeiksz likes this.
  12. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,355
    Is this issue still going on ? I cannot use URP at all if this simple base feature is not working
     
  13. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    162
    It should work, when this issue was fixed in 7.2.0, I created a test scene containing every URP shader opaque and transparent and all of them receive shadows.

    If this is not working then that is some bug I haven't been able to reproduce and would love to receive a bug report about it.
     
  14. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,355
    Hi, thanks for the response.

    Is there a way to get an insight of what the fix was ? I have a shader based on URP Lit one, i started it on LWRP 6.9.0, and did some changes as moved to URP. Now i am not sure if is the fault of my shader based on older LWRP or new URP issue. Turning from transparent to AlphaTest works for shadow receive.

    Also is there any news about the slowdowns in Unity editor after Unity 2019.3.1f1, i have sent this bug long time ago and there is no news, this is also crucial for my asset and currently is not working at all after Unity 2019.3.1.

    https://fogbugz.unity3d.com/default.asp?1233944_744uepe09a7cbra7

    Thanks in advance
     
  15. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    nasos_333 likes this.
  16. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,355
  17. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    78
    We updated our project from LWRP to URP and are seeing similar issues. Any chance switching between the two could cause the problem? It's happening with shader graph shaders, as well as built-in Universal shaders like unlit particles. Toggling transparents receive shadows has no effect.
     
  18. Coderious

    Coderious

    Joined:
    Mar 28, 2020
    Posts:
    26
    Hi, not sure if it's the same issue, but the terrain does not receive shadow at all while using the default terrain shader (URP/Terrain/Lit). The shadow works fine if I switch the shader to hidden shader Hidden/Universal_TerrainVisualization, which I came across trying different shaders.

    The problem is that I can't add layers on the Hidden/Universal_TerrainVisualization. I tried manually updating the default shader to mimic the hidden shader without success.

    Any advice how to make the default TerrainLit shader receiving shadow?
     
    chillcarrier likes this.
  19. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    425
    Any luck solving the problem? I still have no shadows casting from transparent objects, they get painted as soon as I switch the material to opaque.
     
    UserNobody likes this.
  20. UserNobody

    UserNobody

    Joined:
    Oct 3, 2019
    Posts:
    144
    In URP 7.3.1 when using Lit shader and transparent mode doesn't seems to cast shadow. I don't understand how hard can it be to fix this issue.. This thread is almost 1 YEAR old..
     
    brownbomber likes this.
  21. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    425
    A hack to solve it, is just to add a second version of the object with a material set to opaque but with alpha cut out and in the renderer mark it as render only shadows. They should use alpha cut out by default for the shadows or something.
     
    Gravesend likes this.
  22. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    I can try and find out @UserNobody, I'll ask around for you!
     
    UserNobody likes this.
  23. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    129
    Hi Shaun, can you please follow up with this one? This is a long standing issue and if the goal really is to close the feature gap between URP and the Standard Renderer then this is a particularly glaring omission to be left hanging.

    Definitely a pain point for me.
     
  24. Lyxodius

    Lyxodius

    Joined:
    Jun 2, 2018
    Posts:
    5
    @Shaunyowns Any news on this issue?
    This is a really important and basic feature to a lot of people, including me.
    I hope this gets fixed soon.
    Please keep us up to date.
     
  25. brownbomber

    brownbomber

    Joined:
    Jul 15, 2017
    Posts:
    4
    Sometimes I wonder if Unity pays any attention to these posts, and just fixes or updates things at their own leisure!! It really does not seem like they do pay much attention!!
     
    unnanego likes this.
  26. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    unnanego likes this.
  27. Amanecer

    Amanecer

    Joined:
    Jan 31, 2014
    Posts:
    3
    @Shaunyowns
    Hi!

    Any news on this situation? I'm facing the same problem. I want to use 2d plane / sprite as surface for texture that contains alpha channel information. When using URP / Lit -shader on a plane it casts shadows but once I activate alpha (change surface type to Transperent) I loose casted shadows.
     
  28. ivank

    ivank

    Joined:
    Nov 16, 2013
    Posts:
    105
    Maybe not quite directly related, but - is it possible to create matte/"shadow-drawer" effect using the URP?

    In fact it means fully transparent plane, but displaying shadows casted by other objects (see attached example picture).
    For the original Unity 5 renderpipeline the effect was possible via this Unity's Keigiro Takahashi shader.

    Based on discussion above, receiving shadows on (semi)transparent surfaces does not seem to be supported...
     

    Attached Files:

  29. MP-ul

    MP-ul

    Joined:
    Jan 25, 2014
    Posts:
    230
    First go here and open that.

    Then Edit this to true
     
    alanorin, enginx3d and ivank like this.
  30. MP-ul

    MP-ul

    Joined:
    Jan 25, 2014
    Posts:
    230
    Now next on my list is how to fix this darkening
    Standard RP

    URP
     
  31. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Looks like there is no GI or Ambient color (sky).
     
  32. MP-ul

    MP-ul

    Joined:
    Jan 25, 2014
    Posts:
    230
    There is, but is way way darker.
     
  33. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Can you show all settings, materials and lighting window?
     
  34. MP-ul

    MP-ul

    Joined:
    Jan 25, 2014
    Posts:
    230
    It has nothing to do with that, is a simple scene with default settings. It works with the standard shaders, but when you switch to URP in unity 2019.4 the shadows and ambient in general is darker. Is a shader problem not a wrong setting.
     
  35. sinaari

    sinaari

    Joined:
    Jan 28, 2019
    Posts:
    47
    So what's the answer?

    I love it how even you yourself being within Unity can't get any response from others in Unity, for 3 months and at least 2 attempts! And how it's the same sheetuation as when you tried to ask them about the deferred renderer (https://forum.unity.com/threads/urp-deferred.931872/#post-6345231)

    That makes us something like brothers here <3

    I have no idea what's your company's communications model is, but it looks like Unity is unaware that it's possible to actually talk with people, both inside the company and outside (because why, right?). Not much of any unity there is in Unity. A better name would be Obscurity. "Obscurity Engine" -- I like it, pretty much describes the feelings from working with it and from trying to get any support.
     
    MP-ul likes this.
  36. MP-ul

    MP-ul

    Joined:
    Jan 25, 2014
    Posts:
    230
    Well every worker at unity is like that, I have not seen any help given to anyone ever since I joined this forum from one of them, only good people who use unity helped with a mod of a shader or a fix in some areas.
     
    sinaari likes this.
  37. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    I just created a new lit shader graph, applied it to an object and it's not receiving shadows. If I apply the built-in URP/Lit, it does.

    Unity 2020.2.0b14.3668
    URP 10.2.2
    Shader Graph 10.2.2
     
  38. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    141
    I found a shader on URP with an object receive shadow while still transparent. You can also adjust the transparency level.

     
    ivank likes this.
  39. Lynx891

    Lynx891

    Joined:
    Jan 21, 2020
    Posts:
    3
    Hi, this is still an issue, i'm using Unity 2020.2.4f1.

    Changing the Surface Type to Opaque makes the whole plane object cast a shadow, but Transparent does not cast any shadow, can Unity devs please fix this problem?
     

    Attached Files:

    BertrandNM, Spoke44 and soorya696 like this.
  40. vfxjex

    vfxjex

    Joined:
    Jun 3, 2013
    Posts:
    93
    upload_2021-2-23_14-1-50.png

    Bug still exist in 2020.2
     
  41. JRCurio

    JRCurio

    Joined:
    Jan 24, 2021
    Posts:
    1
    We had this issue for leaves but we changed the material to opaque then activated alpha clipping and chnage the values. Hope this helps someone :)
     
  42. Lonnie211

    Lonnie211

    Joined:
    Jul 6, 2013
    Posts:
    4
    thanks for this bro!
     
    VitaPro likes this.
  43. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    upload_2021-6-22_17-21-39.png
    urp v12, still no shadows when a lit shader enables tranparency
     
  44. szsahajsz

    szsahajsz

    Joined:
    Aug 17, 2018
    Posts:
    13
    Will this be ever added? cast shadows on transparent pbr's in urp?
     
  45. CamoTurtle

    CamoTurtle

    Joined:
    Sep 17, 2021
    Posts:
    1
    For anyone finding this because their leaves on trees are NOT casting a shadow with basic URP Lit shader.
    • Switch the material back to Opaque and then check 'Alpha Clipping' instead
    Not sure if this works for other transparent needs, or any drawbacks? I'm a beginner :)
    upload_2021-10-3_10-5-55.png
     
    DefaultPixel92, akaBase and Gravesend like this.
  46. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    425
    Yes, this has already been stated in this thread (many times actually, I think people post before reading). Setting it to opaque also helps with the Z-fighting. But it's not a real solution, just a hack, since it doesn't allow for semi-transparency. You can't have values ike 0.5 alpha, only 1 or 0. I proposed above that you can use the cutout just for the shadow, if needed. Check it out. Still, a semitransparent shadow should be available out of the box.
     
    Last edited: Oct 4, 2021
  47. jwinn

    jwinn

    Joined:
    Sep 1, 2012
    Posts:
    88
  48. stackt

    stackt

    Joined:
    Sep 3, 2021
    Posts:
    1
    Still fighting with this on the latest beta build (2022.1.0b3.2528), and every time I try to modify the URP package it gets reverted
    castShadows.png
    Creating my own shader graph that casts and receives shadows the result casts shadows but is visually wrong when compared to the opaque surface type
    Transparent:
    TransparentSurfaceType.png
    Opaque:
    OpaqueSurfaceType.png
     
  49. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    This is a sorting problem within a single transparent mesh. It’s a classic problem in real-time 3d rendering, and it’s basically unsolvable. You can mitigate it or revise the assets.
     
    stackt likes this.
  50. Dankann

    Dankann

    Joined:
    Oct 25, 2016
    Posts:
    3
    For anyone still having problems with the lit shader not casting shadows when surface type is transparent, try changing the shader from Simple Lit to Complex Lit, that fixed it for me.