2D Fake Height Shadow Problem

I don’t know why it is hard to find good tutorials for this? Only thing i found so far was from GucioDevs :

So i want a fake height shadow for a top down game. I have a parent object that holds the white rectangle as a child and the shadow sprite as a child. to achieve fake height shadow i can move the white rectangle up and down. I hope its clear for what it is. For example when the player is jumping, or an arrow is flying up and down, or a leaf drops from a tree etc…

First problem was, that when multiple shadow overlap the color in the overlap got darker, so i wrote a shader. That uses Stencil etc. Works like a charm. So it was solved.

But now i wanted to have shadows on existing objects that drop shadows. just like it is in real life. so i programmed a lazy script, that adds the local Y position to the sorting layer. kind of works. maybe there is a better solution?

But the biggest problem now is, because of the stencil shader, the most on top object doesnt drop a shadow on the underneath anymore, because it overlaps with the shadow under the bottom object. Hope that was cleary explained? you see that example on the screenshot where two white rectangle overlap and the shadow is cut off. So how could i solve that? i probably would need to also check the sorting layer in my shader, but i have no idea how…

Arent there any tutorials on that topic? There are tons of top down games made with unity. No one uses shadows like this? Or is there another way?

7916890--1010035--upload_2022-2-22_13-48-41.png

the shader stuff muddies the waters for this issue. Almost all games that use shadows like this allow them to overlap, even tho that is not realistic, because its too hard to do it like you want. If you have an example of a game that blends the shadows correctly you can post it as an example but youll find very few that do ( the fact that you believe that most topdown games solve this issue easily shows that even you dont notice the flaw, so its not worth the hassle for devs to break their heads over it )

yeah, lol, yesterday i bought ARCHVALE for example, recorded it and then watched the video frame by frame, just to see, that maybe, i think to much about little things :smiley: