[2D] Z-Ordering Shadows
Hi all,
My team is currently running tests on how to paint shadows and maintain correct Z-Order for when the player walks under a tree or in the shadow of a building (as examples). Our first step went fine, which was to import a tree asset, it's shadow, the player, and the ground tile all as separate PNGs (or a full sprite in the case of the character) and make sure they're ordered in the same way by changing each assets' Z-value.
The shadows look fine on their own and they look fine when the player is in the middle of them, but it falls apart when the player enters and exits the shadow. The problem is that the shadow doesn't play naturally with our character. We have no methods to determine the height of the player, such that the shadow should affect the player at an angle. We also don't have any mechanisms in place to determine the darker parts of the player other than his typical self-shadowing. I'm guessing we could use a Shadow map and do some rudimentary multiplier math to paint places where shadows should be darker/lighter, but I've yet to get good results with that method under higher resolutions (our character sprite is 300x300 pixels and we're using a painterly style - I've only seen that method work with 8-bit blocky art).
Lastly, we don't know what we don't know, which is the worst problem to have. I feel like we're missing something here to make this even better but I haven't figured out what that is yet. Any thought from the lighting gurus out there?
Thanks, Zach
https://forum.unity.com/threads/2d-z-ordering-shadows.508249/ - this is my post in the forums which also shows an image example.
Your answer
![](https://koobas.hobune.stream/wayback/20220612144411im_/https://answers.unity.com/themes/thub/images/avi.jpg)