[Released] Analytic Soft Shadows for Unity

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

Asset StoreWindows Demo:white_check_mark: Built-In (2021+) • :white_check_mark: URP (2021+)

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

Features:
Insane Performance: Due to tiled-culling and depth-aware-upsampling in a lot of cases the performance can be better than Unity’s shadowmapping! (Best case: Approximating high-poly models with few soft shadow shapes. Medium case: Approximating models with hundreds of small soft shadow shapes.)
New feature! Colored Shadows: Each shadowcaster can now cast a unique shadow color instead of black. Example.
• Famous Capsule Shadows algorithm used in many AAA games (TLoU2, CS2, Warframe).
• Real-time adjustable shadow softness all the way from super hard to super soft.
• An additional algorithm option that provides soft shadows that do not fade with distance, if that’s what you want, similar to “Signed Distance Field shadows”.
• 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.
• Full source code included for maximum configurability.

Limitations:
• Built-in: Deferred rendering path only, URP: Forward rendering path only.
• Mobile, WebGL not officially supported. A platform with compute shader support is required.

Enjoy!

7 Likes

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?

Not sure, perhaps in the future. For now I’m focused on research into adding URP and HDRP support

2 Likes

@JollyTheory “WebGL not officially supported” ← does that means that the asset will work, but with decreased performances?

WebGL does not support Compute Shaders so it will not work at all, unfortunately.

@JollyTheory : ok, thanks for the quick answer!

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.

Do you think (or know) if this also works on xbox and playstation?

@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 ?

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.

Not sure, don’t have those consoles to test on unfortunately.

Are there any plans to extend it to SDF shadows?

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.

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.

1 Like

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!

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:

Hi, I saw you were studying the URP, is it going to be inserted? I only work with URP :frowning:

Hi. I just bought this and I’m really impressed with the results, but I’m having a lot of trouble implementing them into my scenes without objects casting shadows on themselves in weird ways. Is it possible to control which objects cast shadows on each other?

I realise my light angle is narrow here. That’s mostly to emphasise the problem, but it’s a major issue with wider angles too.

Try increasing the bias parameter, also try putting multiple smaller capsule casters on the tree and the thin object on the right instead of one big one, that should help.
Also for capsules the Indirect algorithm has less self shadowing, try switching to it if you’re using the Direct one.
For the box on the other hand the it would help to decrease the bias, so the shadow sits closer to the box, did you increase it, or perhaps is the shadow caster size itself smaller than the box?

I increased the bias on the box to exaggerate the problem, but in general I’d like to choose which objects are unaffected by shadows.

The only option seems to be to use a shader that’s unable to receive shadows, but that seems like a terrible solution. I’ll just have to bear that in mind and limit my application of it to the things it does well. In the future it would be great if layergroups could be used to control shadow casting relationships.