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

[Released] Analytic Soft Shadows for Unity

Discussion in 'Assets and Asset Store' started by JollyTheory, Mar 2, 2021.

  1. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    33

    Analytic Soft Shadows is a real-time soft shadowing solution with shadows defined by Spheres, Capsules and Boxes.


    It has bothered me for a long time how unrealistically sharp shadowmaps are, even with tricks like percentage closest filtering, they just don't get soft enough to feel realistic. I came across the Analytic Shadows technique and knew I had to implement it in Unity.


    Features
    • Performance: using tiled-culling and depth-aware-upsampling in best cases the performance can be better than shadowmapping! (Best case: approximating high-poly models with few soft shadow shapes, worst case: approximating models with hundreds of small soft shadow shapes)
    • Famous "Capsule Shadows" algorithm used in many AAA games
    • Real-time adjustable shadow softness all the way from super hard to super soft
    • An additional algorithm to choose from that provides soft shadows that don't fade with distance if that's what you want, similar to "signed distance field shadows"
    • Easy to use shadow-caster components
    • Blends with Unity's shadows nicely so you can mix and match them interchangeably
    • Practically infinite shadow resolution, zoom in as close and as far away as you like
    • Source code included for maximum flexibility

    Limitations
    • No URP or HDRP support, Built-In pipeline only
    • Deferred rendering path only
    • Mobile and WebGL are not officially supported
    • Shaders that don't write to g-buffer cannot receive analytic shadows
    • Maximum of 1024 analytic shadows on screen at the same time
     
    Last edited: Mar 3, 2021
    PutridEx, Mauri and firstuser like this.
  2. firstuser

    firstuser

    Joined:
    May 5, 2016
    Posts:
    93
    Looks great!

    This was really easy to set up, I've tried other lighting/shadow assets and this was probably the easiest. Thanks for that!

    Do you think (official) mobile support will ever be possible?
     
  3. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    33
    Not sure, perhaps in the future. For now I'm focused on research into adding URP and HDRP support
     
    firstuser likes this.
  4. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    134
    @JollyTheory "WebGL not officially supported" <- does that means that the asset will work, but with decreased performances?
     
  5. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    33
    WebGL does not support Compute Shaders so it will not work at all, unfortunately.
     
  6. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    134
  7. passeridaepc

    passeridaepc

    Joined:
    Jun 16, 2019
    Posts:
    115
    Would be really cool to see HDRP support. I've been checking Asset Store for the last month only to see if someone has finally made sdf shadows. Though capsule shadows are not exactly that, I'm still excited to see your work! I hope one day you'll add HDRP support. Would buy it straight away.
     
  8. Alterego-Games

    Alterego-Games

    Joined:
    Jul 13, 2015
    Posts:
    44
    Do you think (or know) if this also works on xbox and playstation?
     
  9. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    134
    @JollyTheory another question : after the compute shader has created the primitive approximation for the 3D model, is it possible to save that approximation to a file in one way or another ?
     
  10. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    33
    There is no approximations being created, you may be confusing this with SDF 3d texture shadows. Analytic shadows are defined by Sphere, Capsule & Box shadow caster shape components placed on game objects, like physics colliders.
     
  11. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    33
    Not sure, don't have those consoles to test on unfortunately.
     
  12. passeridaepc

    passeridaepc

    Joined:
    Jun 16, 2019
    Posts:
    115
    Are there any plans to extend it to SDF shadows?
     
  13. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    134
    Aaah I was confused: in my understanding you were generating the primitives (therefore 'approximating' the mesh) automatically. Now I understand the artist must position them. Thanks for the clarification.
     
  14. nrorn

    nrorn

    Joined:
    Sep 23, 2016
    Posts:
    7
    Hi,
    I'm really interested in your plugin to use in an AR project (mobile+URP). When do you expect to have the URP supported? Thanks and congrats on creating this much needed add-on.
     
  15. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,145
    Interested in this if there's potential for substantial performance improvement over Unity shadows. I tried the demo but it looks like vsync is on? FPS was always 60, even disabling the shadows. And would you mind sharing the documentation so I can see what's involved in the setup, to better judge if it's usable in our projects?

    thanks!
     
    Last edited: Apr 10, 2021
  16. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    33
    Hi, sorry for the vsync mishap with the demo, running it on the 'Fastest' graphics quality should fix the issue. I also did some performance comparisons in this tweet: https://twitter.com/cowsaremen/status/1367575678787477511
    And here's the entire setup process:
     
unityunity