[Released] Analytic Soft Shadows for Unity

Hi, the main issue with mobile support is compute shaders, I’ve tested the asset on one higher-end phone, it worked perfectly, can’t vouch for other models. Switch should probably work.

Don’t need a custom Amplify node, just sample a global “_UASSTexture” with object’s screen uv’s, .x component will have your shadow, you can use it however you want from there

1 Like

This looks really cool!
Quick question, is any form of baking required using the built-in renderer?
Or can I expect the shadows to be projected onto meshes (not Unity terrain) that are generated at runtime?

Hi, everything’s realtime, no baking required.

1 Like

Sorry @JollyTheory couple more quick questions - does self-shadowing work (edit: I see above it does, with mixed results!), and do the shadows play nicely with mixed lighting / lightmapping (shadowmask / subtractive)?

Hi,
It should work with that.

1 Like

Hi, as it is right now the URP version GC allocates about 2kb every frame. I wrote a version that doesn’t do that. However it has it’s own issues with the scene view and maybe multiple cameras (haven’t tested it).
I would also like to detach it from the camera and make every UASS component work on lights.

Are any feature updates planned?
Or is this asset in maintenance only.
@JollyTheory I can send you a copy of what I have right now if you are interested.

Hey, I’m very interested in buying this asset for my game. But I’m not sure if I will be able to run it, since every asset in my game uses a custom Shader made with ShaderGraph and as you mentioned you would need to modify your Shader to receive the shadows. I’m not really experienced with Shaders and use ShaderGraph for that reason.
Would it be hard/possible to make custom Shaders receive the shadows or could you describe what steps would be needed to do that?

Thx in advance!

Name the texture “_UASSTexture” and toggle off “Exposed”
R component will have shadows.

It seems like there’s an issue with point lights in URP (havent tested in standard/legacy render) where their light contribution gets completely removed if there’s a shadow where they’re supposed to shine here.

In the screenshot there’s a single UASS component for the directional light, i also tried adding a UASS component for the pointlight itself - doesnt change anything just makes the shadows get cast from the light also ofc.

As you can see there should be some red light shining where the shadow is… but there’s not, it gets completely removed by the shadow

8418585--1113573--Unity_xsDFP06r77.png

here’s a gif with an exaggerated light of the issue from the post above

8418591--1113576--Unity_K548unSU3X.gif

Try reducing Shadow Strength on the component.

I mean sure that helps, but this should work without that? as it dilutes the shadows too much? Anyhow, I figured out a hack/workaround for now, in the LightingPhysicallyBased_ overrde

 if (uass.a == 1.0) {
        // this means it's the directional world light, so we dont modify it
        if (light.color.r == 1 && light.color.g == 1 && light.color.b == 1) {
            light.shadowAttenuation = uass.x;
        }

        // if this is for a point light, we remove shadow based on the luminance of the light
        else {
            light.shadowAttenuation = min(1, uass.x + Luminance(light.color.rgb));
        }
    }

For the point lights we remove shadow based on the luminance of the color, it works neatly and still allows me to have dark/deep shadows - it might not be 100% correct, but dont need it to be

I just set the main directional light to (1, 1, 1) to identify it in the shader, it’s a hack i know, work for now

Any plans to allow this to work with URP Deferred? Any chance it can work with both?

Hey, I bought the asset and even though I think its really really cool, I’m quite dissappointed that it doesnt work with Orthographic Cameras. Or is there a way to make it work with Orthographic Cameras too? This would be really awesome.

Hi, there’s some complicated math involved with the way the asset does culling and Orthographic cameras that I was unfortunately not able to solve, so for now the asset does not work with Orthographic cameras, sorry.

1 Like

Hi, your asset looks amazing! Are there any plans for HDRP support?

Heya, I’m getting visual glitches using your asset in 2022.1.19f1:

shorttermdependableblackrussianterrier

I also get these errors in the console:

Hi, there’s currently a bug in Unity 2022 that makes _CameraDepthTexture_TexelSize report incorrect values. I’ve reported it to Unity and they’ve confirmed the bug, but haven’t fixed it yet.
Could you try it on your own machine:
Debug.Log(Shader.GetGlobalVector("_CameraDepthTexture_TexelSize"));
^ Does that also report incorrect values for you? It should be (1/resolution.x, 1/resolution.y, resolution.x, resolution.y)

8517287--1135523--upload_2022-10-16_9-51-25.png

Looks like it’s printing 1/x, 1/y, x, y to me

I am having an issue where screenspace UV’s are offset by around 5% though in other shaders.

8517287--1135520--upload_2022-10-16_9-48-14.png

Is 341, 192 the actual resolution of your game view though?