+9 votes

I'm working on a basic tilemap-based 2d roguelike game. Sort of. Anyway, I'm trying to use the a Light2D as the light source for the player character, with walls, floor, etc. in a tilemap. So I have a basic wall tile in my tileset which has an occluder covering the entire 32x32 tile. So if I enable Shadow in my Light2D, using a basic CanvasModulate as the fog of war, I get this:

field of view with black walls

So the shadows are working as I want them to, but the walls themselves aren't visible. As an example, here's what I want it to look like:

field of view with visible walls

So I guess I want some way of casting shadows from the back of the polygon, but for the light to still affect the wall tiles themselves. I've tried messing with the cull mode of the occluder polygon, but the best I get is this:

field of view with weird cull mode walls

I've also tried creating a second tile map and light source which will allow the wall tiles to be highlighted seperately, but then walls behind other walls that should be hidden are visible.

Any ideas? Is there any way I can make these walls show up and cast shadows? Would it be possible if I completely switch away from TileMap and place individual spirtes? I'm lost at this point. Any help would be greatly appreciated.

asked Feb 14, 2018 in Engine by uncleshelby (21 points)

I had a problem with this once, I think I solved it with the Z coordinate.

I am having this same issue. I was able to get the walls in my game to show up un-obscured by shadows when I re-created them as a scene/nodes with a Sprites and LightOccluder2Ds. However, going this route forgoes all the advantages for using a TileMap, which I'd prefer to avoid.

Additionally, I'm having the issue where the shadows cast by the TileMap walls are showing up grey rather than black, and I've been unable to find setting that actually changes the shadow color. (Dropbox link to screenshot.)

Does anyone have an idea of how to resolve these issues?

Having the exact same issue. Did anyone ever end up figuring this out?

1 Answer

+4 votes

So, I was finally able to make it work. All I did was to set the LightOccluder2D into a different Light Mask than the Light2D.

answered Jul 24, 2019 by Wibbly (29 points)

Hello! Can you provide an example?
It's a very interesting question

Ok I got it. but there are still a problem...
transparency problem

As you can see, there are a problem with transparent tiles.
I see the same problem in your example)
also my demo project:
https://gitlab.com/mr.cobreen/godot-projects (too big labyrynth "initial commit")

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.