Search Unity

Shadow performance and quality -- will it be improved? Will we ever get better soft shadows?

Discussion in 'Universal Render Pipeline' started by PutridEx, Jun 23, 2021.

  1. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    I've been talking with a shadow guru and, one of his assets (next-gen soft-shadows) which improves shadows for the built-in RP (must have imo) isn't currently available to URP. Seeing how URP is the 'future' and what unity has been developing for so long. Will shadows improve? while not amazing (hence the asset) built-in provides better performance/quality. It looks like there's nothing in 2021, so another LTS will go by most likely.
    2020 without point light shadows, 2021 without good shadows/performance? :(

    built-in does not require you to cast shadows from geometry in order to receive shadows, URP does. Big performance problem. Plus the whole shadpwma
    To top it off, the shadows aren't great, visually. And URP always requires dynamic lighting on top of the baked lighting.
    Plus the whole sad limitation of Shadowmaps in URP :/

    Personally I was looking forward to 2021, which I personally thought would get URP to the point where it's usable in my eyes. I really don't want to have to start a game with built-in at this point. I want to move on to what's supposed to be the in-development pipeline, the future and all that. And not long-term bugfixing. Years with no improvements/new features because of URP, assuming it'll do these features with more quality one way or another, and not just parity, only to find out most features end up at equal or lower quality features built-in already had for years.
     
    Last edited: Oct 30, 2021
  2. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    A tip for shadows performance:
    In the Unreal Engine 4, only large/big objects have shadows in the far distance...
    But in the unity, you have shadows even on the far distance for small objects

    You can write a simple script to manually disable shadows for certain object based on its distance from the camera
    This will make your performance much better... shadows are performance killer

    About built-in pipeline, its ok and useful for up to 10 years later...
     
  3. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    isn't this already supported?
    https://docs.unity3d.com/Manual/shadow-distance.html
     
  4. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    50
    Hey @PutridEx !
    I couldn't replecate this issue. If shadow casting is disabled, I still see shadows being received. Can you go into more detail about the issue?

    I am personally driving shadow improvements in URP, and this is a significant priority for us. I would love any suggestions or feedback.
     
    Last edited: Jul 2, 2021
  5. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Hey, thanks for showing interest!

    it would be nice to have a recieve shadows option, similar to what built-in had. (I believe it's available as a material option but not per object)
    upload_2021-7-3_15-47-46.png


    Second, and most importantly imo, performance
    It hurts to see how much performance shadows eat when most things are static and never move. Rendered every frame.

    I know HDRP has cached shadows, but I'm not sure if you guys ever plan to have it in URP. I'm sure it's not trivial, but it would be a life saver.

    I also noticed the blob shadows ticket on the roadmap, If we can't have cached shadows, then I'll happily take what I can :D

    For comparisons, this asset provides really nice looking shadows (soft shadows look amazing)
    and other features unsupported by URP and builtin, plus good performance: https://assetstore.unity.com/packages/vfx/shaders/next-gen-soft-shadows-137380#reviews

    but it's only available for built-in.
     
    Last edited: Jul 3, 2021
    NotaNaN likes this.
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I would love cached shadow maps that can be lazily updated (could control per object - determine if its realtime or cached on demand). For example (this is also in Alyx) in VR, I would be building up a cached shadow map at my own pace, usually within the budget of the device (Quest 2 / etc) in the next room or area before the player reached it.

    In Alyx's case, when you let go of moving objects and they settle, you can see the cached shadowmap update with a screendoor effect of the object - a tad polished but you get the idea!

    As you can imagine it pretty much makes shadows almost free for vast levels... dynamic shadows are just way too expensive and not even needed for a large amount of the rendered frame.

    The reason I feel the behaviour should be built in is because it's really a massive optimisation for most devices URP will cover, from mobile to VR. Even high end would benefit from it. AAA games all have this, it's a shame we do not (yet!) :)

    Until this time I have to use a hacky workaround with cookies, and it's not great! but here is hoping that cached shadow maps with per-object granularity makes it's way in sometime.
     
    Noisecrime, r137, cxode and 9 others like this.
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    blending between the cascades would be very welcome.
    also hdrp like update cascades independently by script and cached shadow maps.
     
  8. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    I would like realtime shadows not to be a horrible flickery mess:

    https://issuetracker.unity3d.com/is...s-eulerangles-if-its-y-rotation-is-close-to-0

    Also you can tell when games are made in Unity because whenever you stick your face too close to an object you see a weird garbled mess of shadows caused by devs doing the best they can with the options we have but ultimately not having enough options to solve it when baking maps isn't an option.
     
    joshcamas and PutridEx like this.
  9. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    I'm very interested in this cookie hack - I've been wondering if using cookies could be a way to create hacky shadows. :)
     
  10. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    Cached shadows would be absolutely insanely useful. The massive majority of games do not have a bunch of moving objects, and instead have most of the scene be static.
     
    nice2000 and BonneCW like this.
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, this does not sound very versatile: in order to make a tree cast a cookie shadow it would have to be part of the cookie texture. so it first and foremost would shadow itself?!
     
  12. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    50
    @PutridEx The receive shadow setting is now per material so that you can have sub-meshes and then set shadow receiving per-material.

    Cached static shadows is very high in priority on our raster shadow roadmap. The only thing we actually have as a higher priority at the moment is moving the shadow depth bias from the caster to the receiver, as that would be a huge improvement in quality. Bias improvements need to be done in major release versions, since the upgrade will require you to adjust the biases across all scenes.

    2021.2 now has decal projectors which can be used to render blob shadows (and fake lights). The documentation and sample workflow (by @Jonas-Mortensen) are in progress. We still need to evaluate performance on mobile, but the decals implementation has a really cool performance optimization, which we will detail in a blog post.

    https://portal.productboard.com/unity/1-unity-platform-rendering-visual-effects/c/33-decals

    FakeLights.gif

    @larsbertram1 while cascade blending would be an improvement and it is definitely something we are investigating, it is a bit of a hacky workaround for the perspective aliasing and has considerable performance implications, and I would prefer for us to focus on a smaller improvement that allows us to restrict the depth range so that we do not undersample as badly with negligeble perf impact. I'll go into detail about this at a later time.

    In 2021.2, we also made signficant improvements to the quality and control of shadow fade in URP.

    A critical improvement to shadow frustum culling is currently in progress with regards to culling spheres, which actually affects all SRPs and built-in.

    Slope scale bias is also in progress, though this is something that is interdependent with other biases improvements.

    I'll try to get some cards added to our roadmap with more details about some of the improvements so that you all can vote and help us prioritize them. While some of these are pretty easy to get running on a single platform, getting them to be performant and stable across all platforms can be incredibly challenging, and some of these improvements are inter-dependent as I mentioned, so there are significant considerations especially in regards to other new feautres. We want to make sure that all improvements and new features we introduce are compatible with each other, while also being stable and performant across all platforms. We really apperciate all of your feedback, as it is invaluable to us.
     
    Ruslank100, r137, Claytonious and 8 others like this.
  13. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    129
    That idea of using decals to fake lights and blob shadows is a wonderful option, I'll be very interesting to see what the performance improvements of that are like - I can see that working quite well in stylised games like the kind I make. Looking forward to seeing a blog about that at some point!
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    this sounds quite interesting – in case it reduces the number of drawn shadow casters?
    something i do not really understand (regarding render pipelines) is that unity still draws shadow casters which are fully covered by cascade 0 or 1 also into cascade 2 and most likely into cascade 4.
    although bitsquid/stingray* posted years ago about it and unity started to implement it.
    it just culls way too conservatively.
    so a small flower right in front of the camera might be renderd into all 4 cascades...

    we try to mitigate this by doing custom culling in the shadow caster vertex shader. but this of course is only a small performance improvement as we only save the costs from the pixel shader here. so maybe 6μs instead of 9μs per draw.

    Light.layerShadowCullDistances does not help at all here.

    *http://bitsquid.blogspot.com/2016/
     
    joshcamas likes this.
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723


    Excellent and fantastic. If I may be really bold? Please look at the ability to update these cached shadow maps at a fine grain. Maybe a way to add and subtract objects from it, without a full rebuild (bounding area or something?) so it is something we can really embrace in VR.

    Thanks for all your teams efforts.
     
    NotaNaN and apkdev like this.
  16. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Ran into this today, my feeling is without slope-based depth bias we just couldn't avoid acnes when object faces are almost parallel to light direction;

    in my test, on URP v10 we need depth bias close to 10 to avoid these acnes, that's not very feasible in practice.
     
  17. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Request: We lack cascade blending, which really shows in a painful way.
     
  18. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'd like to make the most of the resolution in some way. Currently I'm doing work on a side view game that renders 3D models (same could be said for top down) and the camera actually has quite a lot of empty space between it and the subject being rendered.

    Are we losing definition (wasting shadow resolution) in this scenario? If so how can we fix it? It would be nice to restrict to a band of interest. The camera's near clip cannot be modified because it is for rendering other non shadowed things.

    #realworldgameproblems
     
    apkdev likes this.
  19. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    92
    Have you tried using multiple layered cameras? Then you could adjust near clip value without affecting areas where it wouldn't work out, right?
     
  20. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Which problems are solved basically in the URP? because the jittering/stuttering of the shadows is something really annoying.
     
  21. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Probably not helpful for your case, but about a month ago I got mad at the shadows. Resolution was bad even at the best settings, artifacts (especially biasing around corners and sharp edges as well as obvious lines between cascades) really started getting to me, etc. So I partied like it was 1999 and made stencil shadows.

    URP shadows (2048x2048, 4 cascades):
    upload_2021-9-17_19-14-28.png

    This seems like it would be an easy case (orthographic camera, single directional light, most things roughly the same same distance from the camera). But it turns out to be a challenging one because artifacts are more pronounced than they would be in a detailed environment (to be fair, the final game will have a lot more detail the solid-color floor and wall of lorem ipsum are for testing).

    Stencils (hard, no AA; I know about the artifact at the bottom of the wall and it's an easy fix I haven't gotten around to doing):
    upload_2021-9-17_19-15-55.png

    Stencils (depth/normal aware blur, still no AA):
    upload_2021-9-17_19-18-8.png

    Code is "open source" but not well optimized or easy to use, and I'm going to rewrite it for culling and multiple lights. I can share it if you're interested. But it'll only work on compute shader capable hardware, which means a lot of mobile/low-end devices are cut off. Performance is not great because of rasterization costs; actual compute shaders are cheap but overdraw is crazy and only increases as the triangle count of the mesh increases. But it's still faster than the 4 cascades.
     
    Last edited: Sep 18, 2021
  22. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    50
    @hippocoder We actually have two new things that will actually help with this problem. We have added a
    shadowNearPlaneOffset to the scriptable culling parameters which allows you to control the near plane for the camera frustum only for the shadow rendering, which I assume is exactly what you need. This is about to land in trunk, so it should be available in the 2022.1 alpha soon. As soon as this lands in trunk, we will try to backport to 2021.2.

    In 2022.1.0a7, we have added a new scriptable culling parameter called conservativeEnclosingSphere. There is currently an issue in the SRPs that was inherited from built-in where the frustum cascade enclosing spheres are misaligned and incorrectly sized. As a result, there is some wasted space behind the camera (and there are some incorrectly culled shadows in the corners of the far cascade). This also fixes an issue with the far plane and shadow fade. If you enabled this setting, you will need to re-author the positioning and size of your cascades. This is currently being backported to 2021.2.

    @larsbertram1 Yeah, the conservativeEnclosingSphere fix minimises the cascade overlap which reduces the amount of redundant static shadow castors. There were a few fixes in the lightspace intersection calculation that landed over the past year. Let me know if you still see a large number of redundant castors in recent Unity versions. We are further investigating the remaining castors to make sure that our lightspace intersection calculation is accurate.

    One other thing we have been considering for investigation is the ability to enable/disable the shadow rendering individually for each cascade. Is this actually something that anyone would use? We would love any feedback about this. This would allow you to use disabled cascades to seperate the distance between shadow maps to maximise the resolution.

    @pistoleta can you share a gif of the shadow judder that you are describing. The shadows in URP use a stable fit solution, and that is a much worse problem in close fit (which is the default in built-in). Note however, if you are changing the FOV between frames (or potentially camera settings other than position and oreientation), you may see this type of pixel crawl.
     
    cxode and hippocoder like this.
  23. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    @nigeljw_unity any progress on the issue I mentioned?

    https://issuetracker.unity3d.com/is...s-eulerangles-if-its-y-rotation-is-close-to-0

    I found it in BIRP but QA confirmed its in URP as well and since its about jittering/shuddering it might all be related.

    It still floors me that this was not solved or even properly addressed. We literally can't have a directional light that slowly rotates smoothly, which causes problems for any 3D game trying to have a day/night cycle. To be honest, its a shocking joke that something so fundamentally basic doesn't work properly.

    I can accept that it could be a big and complex change behind the scenes, but this issue was buried and shows the fundamental oversight of what Unity as a company values as important.
     
  24. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Totally agree... This feels like a bad joke.
     
    LaireonGames likes this.
  25. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Exciting stuff!
    I've seen some of the pulls on github and I'm looking forward to testing them :D

    Although for each day we go without static shadow caching, my hair gets whiter. :(
    I tested HDRP's shadow caching for a long time and it is awesome, seriously big performance improvements.
    I can render the shadows twice every 1 second, and it works perfectly without any shadows popping in etc.
    Compared to 60-100 times per second, when most objects are static.

    I'm also a fan of smooth shadows, nice shadow filtering makes all the difference. To be completely honest I'm more of an HDRP user than URP, but i still have interest in URP and hope it gets better. We shouldn't need an asset to make URP shadows look sexy.
    https://assetstore.unity.com/packages/vfx/shaders/next-gen-soft-shadows-137380
    This asset makes built-in shadows look good. If URP implements some of the filtering and nice soft shadows that asset does, it'll be great. Although the author intends to release it for URP eventually, it's always better coming from the engine itself. For many reasons.

    Although, I do understand and can somewhat imagine how tough it is to get a feature working with all the platforms URP supports, with acceptable performance.

    But it's a bit painful to be held back by said platforms. If someone on PC wants high-quality smooth shadows with a nice blur, they up the shadow settings. If mobile, they stick to something reasonable.

    Shadows can really break or make a scene visually.
    Thanks for all your work, appreciate it!


    I will tell myself that 2022 is the year of URP shadows. I'm sure this is the one time I will be correct :D
     
    Last edited: Sep 21, 2021
    Ruslank100 and NotaNaN like this.
  26. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    50
    @LaireonGames I missed your first post. In the comment about the issues with shadows when the camera is near to the objects, is this issue with built-in or URP? Are you referring to self shadows or shadows from other casters?
     
  27. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    This was originally found in Built In, but I was told it wouldn't be looked into because development was too focused on LWRP and HDRP. Later someone else confirmed it was also in LWRP which might have been Unity QA after I insisted the answer to swap to a RP was utterly unacceptable, especially since that result was given without checking RP first. That horrible experience aside I think this is what eventually lead it to be 'postponed' rather than I think 'wont fix', I've no idea if it was looked at since then so its probably still in URP.

    Its still present in BIRP and the situation I made a scene for was showing the problem as from another caster. I've not checked the scenario where its casting on itself.

    The setup was extremely simple. Take a cube and scale it to be your floor, add another cube that sits on it. Add a script that rotates the transform of an object on one axis and apply it to the direction light. Set the script to rotate slowly, mimicking a day/night cycle, and then hit play. Get the camera close to watch the shadows and now hit next frame (which pauses Unity). Keep hitting next frame and what you should see, really obviously, is that the length of the shadow changes each frame. To be clear, by changes I mean its short one frame and long another in a way that isn't consistent and produces a flicker.
     
    Ruslank100, JoNax97 and pistoleta like this.
  28. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    @nigeljw_unity That shadow plane sounds great for all kinds of limited angel games, thanks! I'll be able to pop over to 2022.1 eventually, and I'm wondering if cached shadows will land in this version.

    Also is there a possibility of caching smooth shadows? It would look a lot nicer for similar cost on old hardware. I suspect it's probably too tricky to do?

    Thanks again for making shadows possible on toasters.
     
    NotaNaN likes this.
  29. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    129
    Hi @nigeljw_unity - a question about your previous post showing the decals as fake lights:



    What changes to the default 'Decal' Shader Graph that comes packaged with 2021.2 need to be made so that the brightness increases for everything the decal hits, like in your gif?

    If I create a scene and dim the lighting, and then create a white-coloured decal pointed at my geometry, it's just as dim as the rest of the scene - what am I missing here?
     
  30. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    129
    Oh! I think I've figured out what I was missing. I had the Decal Renderer Feature on my URP Renderer Asset set to 'Automatic', and changing it to DBuffer got me where I needed to go.

    The docs were helpful on this front, and I plugged in some more inputs to colour multiply the texture and have some control over the emission too:

    DecalShaderGraph.png
    Now I'm going to see whether 1 - it looks good as a substitute for point lights in my stylised game, and 2 - whether the performance is indeed massively better.
     
    morepixels and nigeljw_unity like this.
  31. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Real Time URP Shadows don't have enough room to go around for the shadow maps especially spot light shadow maps.
    I can't even have 2 spotlights in the scene only 1 retains the crispness adding more than 1 will result in blurry shadowmaps and warnings that the resolution has to be reduced to fit the shadowmaps in.

    I found that part of the issue is from Unity adding to the shadow map shadows from gameobjects very far away or even completely out of the camera view. Is that a bug because it's can't be it's extremely poor design.

    Is occlusion culling the only way to make Unit stop adding to the shadowmap for far away and out of view objects I mean the frustum culling sure isn't affecting the shadowmap?
    I've had to set all my lights rendermodes to important because anything else makes the lights turn on and off quite noticeably when the player is near. Also poorly implemented.

    The shadow distance option doesn't seem to matter at all the shadow map still gets affected even if the shadows are not on screen as long as they are somewhere in the level even well behind the character it still adds to the shadow map.

    Good god in 2021 we are still dealing with 1990 implementations of shadows.
    Something's got to change.
    We definitely could also benefit from a crazy shadow denoiser.
    Yes I am saying the max distance is bugged and doesn't do anything as even shadows that are invisible at a certain distance such as 50 Unity's shadow casters count is the same regardless of distance and so is the shadow map resolution unchanged it's still piss poor only changed by light count.

    Having said that though that's like my only complaint with URP I'm lovin it (TM).
     
    Last edited: Oct 28, 2021
  32. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    @nigeljw_unity any ETA when it'll drop? loose hand-waving is fine...
     
  33. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    Can you post an update when you figure out these things? I'm curious :)
     
  34. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    I wonder if we can get contact shadows in URP :)
    Would be quite nice
     
  35. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    UPDATE: I need help, I have literally 1 point light in the scene which barely covers anything and I am getting that message each time I enable it saying that "Reduced additional punctual light shadows resolution by 4 to make 6 shadow maps fit in the 4096x4096 shadow atlas."
    I'm stumped and am going to file a bug report.

    I found out just now that even though I am getting spammed with messages about "Reduced additional punctual light shadows resolution by 2 to make 2 shadow maps fit in the 4096x4096 shadow atlas." from the spotlights that I use that scaling my main character by 5 x bigger makes the message still show but the shadows become very crisp!
    I work in accurate meters so this doesn't make any sense.

    You would think a smaller character would take up less space on the shadow map.
    I still haven't figured out a workaround to the shadow atlas being filled up I only have a couple spotlights in the scene and Unity says around 110 shadow casters I cannot get crisp shadows for my character no matter the settings I use except in URP except by scaling my character up 5 x bigger than normal. Anyone help or should I report a bug?

    4096 x 4096 resolution for a shadow map in 2021 what a joke I don't get how GPUS can handle so hundreds of textures in a game but only 1 shadow map for a spotlight.
     
    Last edited: Oct 30, 2021
    joshcamas and PutridEx like this.
  36. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Quick review of the 2021.2 update from an actual URP user:

    Honestly the latest 2021.2 update did jack all for the URP at least in regards to key issues.
    -Shadow quality and approach is still garbage and has not changed AT ALL.
    -Shadow Rendermode auto is still broken af and you'll see popping of lights everywhere you go which will force you to set them all to important rendermode which is not recommended..
    -The bug of not being able to detect how close the camera is to a light in order to show it and apply shadow atlas space or not is still present and lastly our favorite spamming of needing to reduce shadow resolution is still there.
    -Importing of assets does seem a bit faster but the 100% cpu bug is still there.
    -Some of the UI changes are questionable and now under every game object, camera, light etc all the settings are hidden under tabs you have to expand over and over it's become Zbrush UI now.
    -The Unity logo was hacked and changed and no employee was able to notice...sigh :p.

    So the claim by the Unity developers is that this update was a URP one are clearly not actually making real games with Unity. This was supposed to be the update for URP I am having a really hard time believing Unity isn't going bankrupt like the engine literally is holding developers so far back from finishing a game they're getting wedgies.

    Verdict:
    If you use urp like I do don't bother with the upgrade from 2021.1 to 2021.2 it literally will only set you backwards
    breaking many of your plugins that are not yet updated for it yet and you'll get nothing in return actually.

    P.S. I didn't bother reporting the bug and because I plan to additive load scenes occlusion culling might not be suitable to hide these extra lights - it might just be overkill too. In any case I ditched the many shadow casting lights in favour of 1 point light that follows the character wherever he goes it's actually quite effective because wherever you go there will be fairly crisp shadows.
    Achieving the same effect with spot lights and directional is difficult because when your camera rotates the shadows will rotate with them but it's much less noticeable with point lights.
    So I am happy with this hack if you will now I don't need to worry about any kind of optimization and even though the warning about resolution is still there the shadows are still crisp enough and there's no other shadow lights so I can ignore the warning and have many many lights but just 1 key shadow casting light that goes wherever the camera goes. Yay me I'm so smart. ;)
     
    Last edited: Nov 5, 2021
  37. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    You can lower the resolution of the light. The message will still be spammed eventually, but one low-res light (6 maps at 512x512) won't take up a whole RT.

    It just draws the scene from the POV of the light (6 times; one in each direction). So something that's either closer to the light or larger will get a higher quality shadow than things smaller of further away. Reduce the radius of the light and you'll get higher res shadows.

    https://catlikecoding.com/unity/tutorials/custom-srp/point-and-spot-shadows/



    I agree it's a major problem and Unity should fix this. However, if you're just trying to get something done or ship a game some time in the next year, it probably won't change, so it's time to start looking for workarounds. Here are some things you can try:

    1. Bake as many lights as you can (if your game is amenable to baking) instead of making them realtime.
    2. Replace point lights with spot lights. You can usually estimate a point light with 1-4 spot lights.
    3. Reduce radius distance (and intensity to match), then move the lights closer to the shadow casting objects.
    4. Use soft shadows. These are more expensive but blur out the artifacts.
     
    Last edited: Oct 31, 2021
    SilverStorm likes this.
  38. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    @no update on why my shadow map resoluti
    In the end I ended up choosing to have many point lights in the scene for the lighting with no shadows. I could bake them but Unity handles them fine as long as they don't have shadows I generally try to avoid lightmapping like the plague in Unity it's baaaad.
    I then attached a single key point light with max shadow resolution onto the player's camera so wherever they would go it would be lit with crisp shadows. There is no downside here with the minor thing that if you look closely as the player rotates the shadows rotate slowly as well but it's hard to notice unless you look for it. It's a lot more noticeable with spot lights and directional lights so point lights were my choice for natural in door lighting.

    The beauty is the shadows are crisp despite the warning still being there. So long as it's just 1 light of any type that has shadows enabled Unity handles it fine. So as far as I'm concerned this problem is solved yay!
     
  39. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    Here it is lads nice clean and crisp shadows of ma game:
    Although Youtube didn't take kindly to a 1440p cropped resolution...so video quality is not great.
     
    Last edited: Nov 1, 2021
  40. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    50
    @hippocoder did you mean the shadowNearPlaneOffset or static shadow caching?

    The shadowNearPlaneOffset scriptable culling parameter landed in 2022.1.0a12. The backport to 2021.2 is still in flight. Something like this is a lot harder to get approval for a backport, as it is technically a feature, but it provides a workflow to greatly increase shadow quality, since you now have scriptable control over the near and far plane for shadow camera frustum as it is decoupled from the camera frustum for the main pass. While this was a little feature, it was one of the highest priority improvements, since it unlocks dynamic cascade placement (though be sure to increment cascade size relative to shadow map texel space to avoid shimmering particularly for XR or just minimize the updates across frames).

    The conservativeEnclosingSphere scriptable culling parameter that I mentioned landed in 2022.1.0a7 and 2021.2.0b15, which fixes the cascade position and size. There is also a URP asset helper API and UI setting that landed in 2022.1.0a12 (shadow settings in the URP asset). I can't express enough how important it is to enable this. Hopefully this becomes default behaviour for 2022.1, but I need more user feedback on it first, so please test this for me if at all possible. It fixes all of the follow issues and probably more:
    • Shadows are currently being culled erroneously along the far side of the cascade enclosing sphere
    • Removes the redundant shadow map space behind the camera
    • A bug with shadow fade and the far plane
    • Cascade overlap which adds redundant static castors, which can affect performance
    Both of these together can provide a moderate increase of shadow quality, but this passes some burden of complexity to you, though it is always my preference to profide a way of user control and customization first before abstracting anything away from the user and into implicit magic in the SRP. It is a lot easier for you to provide a custom solution for the specific scenes in your game than it is for us to provide a single solution that works for everybody, which is why we are initially focused on these lower level scriptable improvements, though we will try to also add helper settings when possible.

    I can't provide an estimated release for shadow caching. :( The only thing correlated with this that I can say is that there was a massive improvement in texture atlasing system in 2021.2 for URP that was necessary for light cookie support and alignment with HDRP.

    @SilverStorm Do you mean the issue with the holes in the shadow? If so, have you tried setting the Shadow Near Plane Offset on the directional light? This is the near plane for the liught frustum and not the camera frustum. Have you tried reducing triangle size by increasing polygon count (this keeps large geometry from cross the near plane)? This also has to do with depth clip space which is a bit ambiguous and not well defined across APIs and devices. I have a PR that provides explicit control over the the depth clamp/clip raster state and shadow pancaking seperately, but we are still discussing how we will approach this issue for full platform reach, and clip space adds significant complexity to the user control. Let me know if I have missunderstood the issue you describe here and if so, what do you mean by "apply shadow atlas space". Also, correlatedely for geometry that is near to a light source, it is better to use light cookies. Your game looks awesome, btw! From some view directions, there are holes in the shadow. Have you tried decresing your normal bias offset to reduce the holes? Or does the increase in projective aliasing from reducing the normal bias then become a problem for geomtery orthogonal to the light? This issue is worse for larger polys as well.
    The main problem is the current enclosing spheres used in frustum culling, as the spheres are currently much larger and not in the correct position at the moment. Enabling the conservativeEnclosingSPhere setting should improve this, though you need to re-author your cascade positions after enabling this (just turning it on may may the shadows look worse), but the enclosing spheres are actually much tigher, and you just need to shrink and re-position your cascades, which will reduce the perspective aliasing (and also reduce static castor count).

    Improving the depth and normal biases are the next major improvement that is highest in priority. This a pretty large task: bias to receiver + slope scale bias + bias scaling approximately relative to perspective aliasing, etc (while HDRP has slope scale depth bias it is actually missing the depth bias clamp at the moment which is important when approaching orthogonality to the light and necessary for the feature), and these changes can only land in a major release as it will require re-authoring of scenes, and this isn't something where the old code path can be left around with an enable setting, as it would cause signigficant code bloat and limitations.

    @PutridEx While there may not yet be parity of features, URP is already significantly greater than built-in. A lot of the really challenging problems for the SRPs are issues that have been inherited from built-in. There is a lot of affinity and nastalgia towards built-in, which is amazing, but it would help the development of the SRPs significantly if everyone moved to URP or HDRP, and if more people move to more recent Unity versions. I fully realize how incredibly challenging this is at the moment for you, but there are really significant improvements in 2021.2 way beyond just the high level rendering features. One of the biggest improvements is in shader stripping in which there are some very significant improvements, which should drastically improve iteration time. 2021.2 was truly a monumental release and it has provided a path towards parity with built-in and alignment with HDRP.

    The main reason this limitation still exists is because extending it beyond 2 objects is due to a limitation in the old built-in backend with regards to culling, and increasing probe count while maintaining performance is dependent on our new forward plus clustered rendering solution, which has actually landed in 2021.2 in experimental. Forward plus removes some of the most significant contraints on URP that were inherited from built-in, which will unleash the capabilities of URP.

    I know we talk about the platform fragmentation a lot, but the image from Natalya's presentation at Siggraph this year really converys the magnitude of the challenge we face together with all of you. Maintaining the same quality of shadows on all these devices is a monumental challenge. This level of device support takes such a massive team of amazing developers, QA egineers, tech artists, UX and Docs, and users, who are all working so incredibly hard every day. I have so much faith in the amazing group that have come together at Unity who are entirely focused on URP. It is just going to still take some time to get past a few of the more painful remaining issues.
    http://enginearchitecture.realtimerendering.com/2021_course


    Sorry that we haven't replied yet to all the comments and questions! There is so much to discuss in this thread and I'm still recovering from a really bad cold. We will try and follow up on as many topics as we can cover in this thread, but for a lot of these tangential issues, I strongly recommend submiting a bug report so that we can actually prioritize the fix, and also start other forums threads on the topics if one isn't created already. These forum posts and bug reports help us significantly.
     
    KenjiJU, Claytonious, cxode and 8 others like this.
  41. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Really fantastic, thank you :)
     
    NotaNaN likes this.
  42. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Modifying the URP files really made appreciate the work you're doing. There's so much going on below the surface for compatibility, or just the number of features/permutations to support. And let's face it, HLSL doesn't exactly make modular code easy to write.

    Like anything else, you'll see a ton more complaints and issues than you will see positive reactions -- when something is just working fine, I don't need to file a bug or complain about it on the forums. But that doesn't mean we're not appreciative of the work y'all are doing to push URP forward and keep it running smooth on a variety of devices, for a variety of different use cases.
     
    NotaNaN likes this.
  43. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    712
    I still stand by that Unity needs to hire a team of developers whose sole purpose is to use the engine to make many types of video games and they give direct feedback to the Unity team. It is not practical or fair to have us developers have their projects delayed to have to report these issues many of us are hit hard by these problems.
    In all honesty some of these issues are so bad that there's no way these could have escaped user testing as they were present in the very first releases of URP like the not so well implemented shadows in URP have been around for over 3 years since its release and only now are people addressing it slowly and releases are coming for it in 2022-a version so out there with so few asset store plugin support that upgrading to it WILL NEVER happen.

    Developers like myself have little time or interest anymore in reporting any issues we just like to find workarounds as I ended up doing for my game as I posted a video above. The reason we try to find workarounds is because the back and forth can take weeks and and your bug will be solved in the next update which is not always feasible to upgrade and features like this shadow fix might be a whole next generation update.

    I've told Unity many times that if they hired dedicated teams of proper developers who actually make games their entire model would change for everyone. This is the reason Unreal Engine succeeds over Unity in these aspects as their engine prioritizes features first. Others may say we got HDRP but as you can see the number of bug fixes for HDRP is still massive and abysmal performance and inability to optimize it especially in shadow casting and mesh combining makes it unusable also whereas Unreal Engine is still far better.

    I'm still Unity for life since I found my place in URP and combined with the asset store its a powerhouse but the fact that not a single asset store developer has released anything for improving shadows for URP it's very problematic.
    As far as I'm concerned I will be using my 1 shadow casting point light following the player/camera workaround from now on for all indoor scenes with the rest of the level being lit by other non-shadow casting point lights. Never again gonna cast shadows on more than one light.
     
    Last edited: Nov 5, 2021
  44. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    Its far more than this and frequently nothing to do with affinity or nostalgia. As an example this is an old trailer for my project:



    The lighting here is a huge part of our style. The night time glow, also an iconic part of our theme and of course all of this is done with custom shaders. The volumetric light is from an asset I bought on the store that is now depreciated, but it looks so good that I've kept up support myself.

    Now, its main shaders are literally 1000s of lines long. Can you imagine that in a node based system? I hate working in nodes as it is, but converting that complex a shader as nodes is just not feasible/sensible/sane. Add that its not even my own systems on top of it... ouch.

    This is just one of the packs I've bought from the store, I forget what else is in there that would need a similar treatment and the problem is that once I get say 75% into the absolute madness web of shaders involved the chance that I will find something that is a show stopper and not supported is far too high.

    As a result, its far too big of a risk to even try to swap. Too much up front conversion time. Too high of a risk of a feature not being support yet and what would be the gain of all this? So far, nothing. Being on the latest but still not finished pipeline? No thanks. Better quality? Not for URP and with HDRP the performance cost is still too high. Latest features? Most of the time I get better performance implementing them myself, also Unity is so far behind in graphics tech its painful so if I do them myself its probably 3 years earlier than I get them with Unity.

    As for the store itself, I'm a publisher there and I refuse outright to support SRP as do many others. We do this because its still a badly lead nightmare of no documentation + black box code + regular breaking changes. This is horrible but to me the main thing is the customers. I'm just going to come out and say it, asset store customers can be the worst and I think Unity is a large part to blame. We sell something slightly technical and you inevitably get angry customers who expect the world and think they know better because they have 10% of a game built. The problem is that Unity started out all of this SRP madness with lies. Lies that its significantly faster, this was only true when you had built a game badly. Lies that URP was better, even though it was severely lacking in features and still is lacking. Lies that URP was 'production ready' even though years later breaking changes to core systems, like having more modern shadows, are still a part of its every day life. Blatant lies that Enlighten support was dropped because of a license issue.

    How this relates to the store is that publishers on the asset store now have to be the one to explain these lies to their customers.

    "I just updated my Unity version and now its broken, 1* review until its fixed".

    "Love the product, when is URP support coming?" "Its not, because URP doesn't support the features we need." "Oh, 4* review then but you get the 5th with URP is added ;)"

    What Unity has done has lied to their user base that doesn't know any better to got them to switch to URP, so now I know as an asset store publisher all my problem customers will be in URP. At the same time if I do support URP I have a much harder job tracking down which SRP they use, which Unity version, what other assets they have bought that don't mix well and what changes they made without realising.

    Its just a nightmare environment but knowing we are there because of lies was the last straw for me. I wont cover for Unity's mistakes. Unity told their customers far too early that URP was production ready and that it was better. At the time, this was simply not true.

    So no, affinity and nostalgia are not the reasons why I stick with built in. Its because of necessity, stability and clarity.
     
    Last edited: Nov 2, 2021
    andreiagmu and Noisecrime like this.
  45. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Unfortunately 2021.2 totally broke shader stripping for projects that want to have both HDRP and URP assets at different quality levels. I get this is not intended workflow but it did work on older versions - or at least shader compilation times were acceptable on them, now it's going to take whole day even with half empty test scene.

    I get this is a very niche use case but would be still nice if the shader preprocessors wouldn't make such assumptions based on specific setup, or at least have option to let their shader strippers only affect their own shaders and not throw other RP's shaders away immediately.
     
  46. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    You actually don't need to use the shader graph for most special effect shaders; they'll work basically as-is. Node graph replaces surface shaders. But even then, you can work mostly around that using custom HLSL functions: https://docs.unity3d.com/Packages/com.unity.shadergraph@12.1/manual/Custom-Function-Node.html .
     
  47. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    There is also work finally starting on a proper shader system:

    https://forum.unity.com/threads/focusing-on-shaders.1171444/

    However this only happened after it taking 4 months to start a conversation so who knows when it will actually be finished:

    https://forum.unity.com/threads/package-requirements-in-shaderlab.1108832/page-2#post-7507949

    Otherwise I didn't know about the custom function node and it sounds like a step in the right direction. Still not enough to make up for the mess SRP have been, or to make me feel confident that switching wont be an absolute nightmare with almost no benefits once its done
     
  48. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    your post was quite help to have an idea of how challenging it is to support all these platforms.
    It really is quite the task.
    I suppose this is where HDRP shines, only focusing on consoles/PC. Without mobile/switch/all other platforms holding back development.

    One suggestion though:
    Can we get an 8k shadow atlas. :(

    About the caching.. It's disappointing that there's no ETA, but I will hold hope for it to land in the 2022 cycle.
    Great to hear about the shadow improvements that landed recently.
    Plus all the other improvements and features in 2021.2, I read the patch notes, big update :)

    About built-in nostalgia, I really don't think it's that. Not to undermine any of the team who worked on SRP, but URP was(still somewhat is) seriously lacking for a long time. 2021.2 is indeed a big release, and a big step -- but even now, it's still lacking some features. Although it's pretty close.
    From a rendering perspective it's amazing, much more open and embracing C# (big win!) which is great. Performance too, and the whole underlying magic going on.
    Forward+ is going to be a big deal, looking forward to it

    but from a purely graphical features perspective it's still not there. Especially when you include all the assets available for built-in offering volumetrics and other big features that have don't support and have no alternatives in URP.
    Which is disappointing, it's been quite some time. I'm hoping 2022 will be a big year for URP shadows, but who knows.. not me :D

    And about customizability, you guys really shouldn't shy away from it.
    I personally, and almost every unity developer I've spoken to _loves_ having a choice. Options. Not every unity project is the same, and although we're no graphic programmers, we can handle some parameters ;)

    That's actually one of the great things about unity assets. Developers always load it with public parameters, and you can adjust it to your heart's content.
     
  49. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    One thing that BIRP can do that neither URP nor HDRP have tackled is NPR. For example (warning awful music):

     
  50. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @nigeljw_unity,
    Regarding performance, there's a nasty Light Layer bug In UT2021.2/URP12.1, that prevent shadows in URP being optimal. I reported the bug, # is 1379540. The bug contains repro instructions and a video.
    But to put it short, after you switch to Light Layers in URP Settings, the light won't affect any renderer that wasn't previously set on his Culling Mask, even if both the light and the renderers has the same Light Layer.
    Also if you switch the light type between Point (or spot) to directional the light culling gets wonky, everything start to cast shadows in the scene, even when they are set to certain layers. Probably a by product of the same bug.
    Bonus: I added an optimization to URP that you might be interested into, is a sort of Substractive Light mode that allows baked renderers receive all shadows from dynamic objects while having static GI and dynamic specular from directional lightmaps. Example video (notice no dynamic light is being computed, only shadows are fetch):

    [EDIT] I also added 7x7 PCF filtering and slope based bias to URP shadows. Currently figuring out the orthogonal problem that it produces. Soon to work on PCSS filtering for URP.
     
    Last edited: Nov 10, 2021