Please help me understand and implement shadows in an isometric game

Godot Version

Godot 4.3

Question

`Please help me understand and implement shadows in an isometric game. The thing is that I want to create a game with procedural generation (I have already successfully implemented this) and the recreation of shadows from tileMapLayer objects. I have already experimented with shaders, but they only worked at the tilemaplayer level. I tried to use a viewport, but I still could not understand how to implement it and how it works.

I saw how another person did it, I will attach a screenshot and a link to the video, but in the final version I just don’t understand what’s what, because I’m a newbie and I just can’t sleep anymore because I want to implement this and I feel depressed because of the hopelessness. Please, if you have any developments or documentation on how to implement this correctly for a newbie, I would be immensely grateful.It would help me if you could describe the approximate scene hierarchy for this or a video. Thanks.


(https://www.youtube.com/watch?v=UavoVWHrebM&t=16s&ab_channel=JohnBrx))`

Both of the techniques that the person talked about in the video are quite easy to achieve, but you need to go step by step.
First you need to understand what normal maps are and how they work, after a very quick search online, I found a tutorial specific for Godot that explains how it works with a step-by-step example:

The second part, which are the actual shadows, are even easier in my opinion. You simply need to make a node that you can attach to a scene, which will take it’s sprite object, duplicates it, rotates it based on another value (or a fixed value if you want your shadows or camera to never rotate), and place it under the object. You essentially use the same sprite as the actual 2D sprite, you just duplicate it and flit it upside down, and make it dark / slightly translarent.

Embrace the fact that you’ll be experimenting a lot. Try something, see how that looks, if it looks really off, start adjusting it, changing values, launch the game again, see how it looks. Still off? Keep changing values until you get it just right.

1 Like

Thank you very much, I thought about it, but I thought it wouldn’t work with procedural world generation, to somehow attach this shadow sprite to a tile from tilemaplayer. Is it possible to implement it via a script, if so, what is the script for?

You can simply modify the objects you spawn to include your modifier node / code. Generating your world just means you don’t deliberately place you items around the world but you let a piece of code do so. But that still requires you to make the objects it’ll spawn / generate in the first place, so you can make them any way you want.

1 Like

Thank you, I’ll try to implement this today, at least shadows seem much more difficult to me than normal maps :slight_smile:

I’m quite interested in this too, but what I don’t understand is what you mean by objects being spawned. It’s a Tilemap, so no new nodes are being instantiated that I can attach shadows to, unless I’m misunderstanding how the tilemaps work?

It seems I didn’t quite understand how to put a sprite texture under a tile from a tilemaplayer. For me it turned out to be complicated and this is exactly what I don’t understand how to do.

Ahh, I see the problem, if you ONLY use tilemaps and absolutely nothing else in your game, then I’d still recommend a shader approach as well.

I assumed that you only use tiles for the base layout of your map, not for more complex objects.

However, if that’s the case, I can’t really think of any other solution than a shader based ones. I don’t have too much experience with writing those, but someone else might be able to help with that.

It’s a pity, if this was the problem, it would be solved, but unfortunately, no matter how much I try, I can’t. But never mind, thanks for the response! I’ll look into it further.

TileMapLayer can be stacked, and tiles can be translucent. I’m using this myself in my game to do damageable terrain.

You could split your terrain into three layers:

  • ground
  • shadows
  • decorations

For this, the scene you show above would have the sand/water in the ground layer, the trees and cacti in the decoration layer, and the shadows in the shadow layer. Since it looks like you’re doing a tactical game, you could also add a grid/highlight layer above “shadows” but below “decorations”.

Hi, thanks for the advice! Do I understand correctly that the shadow layer will be inherited and connected programmatically? Or is it used only for drawing under the scenery? I’ll try to read and see how to implement this, for now I’m trying some fairly complex method, if it doesn’t work, I’ll try yours. Thank you.

I’m suggesting you’d manually populate the shadow layer. So if you had a palm tree tile on the decoration layer, you’d also add a palm tree shadow tile to the appropriate tile of the shadow layer. Whenever you place a decoration tile, place the corresponding shadow tile (if any).

Tilemap layers have a controllable depth, so you could also put character sprite shadows below the decoration layer but above the ground layer.

It’s not “real” shadows, but you might find it’s a quick hack that looks good enough.