2D URP Top-Down game sunlight shadows ideas?

Hi,
I am currently experimenting with 2D URP Lights by creating simple city life game.

The night lightning is looking good, simple road lights are doing the job well.

But at daytime there are no visible lights, the environment looks boring, and I wanna ask you about creating sun light.

Do you have any ideas how could I implement sun light shadows? I tried with creating huge Light2D and using ShadowCaster2D for all buildings, but shadows are infinite, they are the same length like the light, so it is not looking like a real shadows.

Thank you so much for any replies,
best regards!

  1. Easy solution: have baked semi-transparent sprites on a Shadows tilemap that during daylight you fade in. These fade in and out, but do not rotate with the direction of the sun. You can control exactly how they look easily. Many games go with this and it looks good.

  2. Harder solution: you can carefully craft shadow blobs like in (1) but then also set the tilemap.orientationMatrix to rotate / reposition those blobs over time as the sun position changes. This may be a bit tricky to get blobs that look quite right.

  3. Use freeform lights and manually craft lit / unlit areas.

  4. Add cloud shadows. This could be as simple as a full-screen sprite that you scroll noise rolling noise over, or hand-crafted cloud shadow shapes - depends on style preference. The movement adds life to the scene.

1 Like

There is a pretty good sunlight and sun shadow solution in the happy harvest demo

PS: 2d soft shadows are available in the newer unity versions

1 Like

I am currently using 2021.3.17f1 version, but I want to switch to 2022.3.16f1 soon.
Is URP better on 2022 version? Or should I try even 2023?

Not sure if they have soft shadows in 2022; I am using 2023 alpha version right now. You should probably use at least the happy harvest demo’s Unity version.

You can check what is new in URP page for 2d soft shadows and download the first version they have the 2d soft shadows or something.

They also have added additional features like more shadow caster options, tilemap shadow caster( not 100% sure on this) etc.

I tried some things with freeform lights and that’s the effect:

It looks really cool.

Thank you all for help!