Search Unity

2D - Z-Ordering Shadows

Discussion in '2D' started by Zooch, Dec 10, 2017.

  1. Zooch

    Zooch

    Joined:
    Jul 8, 2012
    Posts:
    5
    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. Here's the result of that first step:

    ShadowTest02.png

    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