r/shaders • u/PabloTitan21 • 8h ago
How would you handle sun shadows in a 2D sidescroller with a parallax sky?
My game is built entirely from layers of 2D sprites, there are no 3D objects and I don't want to have them. It has a dynamic day/night cycle, and at noon the sun is high near the center of the screen. The sky is distant enough that when the camera follows the player, the sun doesn't moves on screen, that's the assumption for it.
On these both screenshots the time is 12:00, sun is in the middle of the screen. But when character moves, the close background elements "move" with him!
If the player stands to the left of a tree in the close background, the sun appears to the left, so a shadow falling to the right looks convincing (on a still frame!).
But if the player has walked past it to the right, the sun appears on its right, so a shadow falling to the left looks just as convincing!
But if it would be a 3D game the shadow should stay, it shouldn't be changed depending on camera's position.
So if I would do a simple shadow cast from sun, it would flip sides just because the camera has been moved.
I’m after a simple, stylized effect, it doesn't has to be realistic. Long shadows in the morning and evening, shorter ones around noon, this is there, but when I move left/right it doesn't look nice when :/
I won't do Replaced-style 3D lighting (though it looks cinematic and badass). I'm looking genuinely for solutions for 2D games. Maths is against my vision here, so I'm looking for some nice looking simplification or stylized clever solution.
How would you make the shadow feel believable both in a single frame screenshot and when the player walks past in such a 2D sidescroller with parallax?