![]() To wire-in the occlusion for a single player light, you need to place culling occlusion line-segments on every edge of visible walls that isn't shared with another visible wall. What the Hero Sees and the FOV topic on RogueBasin. I'll try to put together a simple demo, but the visibility algorithm is described much better than I could in lots of places e.g. ![]() Update: I've created a demo project demonstrating this technique - llasram/godot-visibility-demo. Hopefully that definitively answers this question! The problem is knowing which shadows are undesired, which probably devolves once more to implementing tile-based visibility, only now either doing it in a shader or communicating it to a shader. Within CanvasItem shaders, the light() function can modify the value of SHADOW_VERTEX to redirect a shadow which would land on a given vertex to land on another vertex instead. This one is purely speculative, as I haven't spent enough time to see if could be made to work. Use a CanvasItem shader with a light processor function to redirect undesired shadows.(This is what I believe Wibbly is describing in their posted answer.) This prevents any wall from casting shadows on any wall, which leaves all walls visible, but does cast shadows on other objects with the appropriate light mask. Give the wall texture tiles a different light mask from their associated occluders, and set the shadow mask of all lights not to include the wall textures.For walls for example, this could involve designing wall tiles to have a visibility barrier down the center/cornering for every possible orientation or splitting walls into two sets of tiles, with one including the majority of the visible portions and the other primarily/exclusively just blocking light. Work entirely within the engine 2D lighting system by designing your tiles to incorporate hard visibility barriers.Partial/alternative solutions, which may work for some people: I have managed to implement this and get exactly the effect I want. Using 2D shadowcasting for the visibility algorithm allows the result to be integrated into the engine 2D light system by placing occlusion line segments at the boundaries between visible and non-visible tiles. Implement tile-aware visibility behavior in your own game logic.So, what I believe to be the best/real solution: I do not believe it is possible to implement this behavior using only the primitives provided by the Godot 2D light system and no additional code. But if the line of tiles is viewed head-on, then the first tile should cast a shadow on all the subsequent tiles. If the line of tiles is viewed obliquely, with all the tiles directly visible, then none of the tiles should cast shadows on each other. To see why there probably couldn't be an engine-based solution within the existing light model, consider looking down a line of wall tiles. Nothing in the light system has any concept of tiles, and every way of integrating tiles with the engine 2D light system - including built-in TileMap - must work in terms of tiling occlusion polygons, which necessarily results in walls covered by tile-sized occlusion polygons casting shadows on each other. The key concept is that the 2D light system is a physically-inspired model of light in a completely 2D space, optionally allowing line segments in the space (and hence polygons composed of them) to block light and cast shadows when the light enters from one or both sides of the line segment. ![]() And the one posted answer is wrong, or at least woefully incomplete. This is an old question, but I ran into the same issue and had the same incomplete understanding of the Godot 2D lighting system prompting it. 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.Īny 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. I've tried messing with the cull mode of the occluder polygon, but the best I get is this: 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. ![]() As an example, here's what I want it to look like: So the shadows are working as I want them to, but the walls themselves aren't visible. So if I enable Shadow in my Light2D, using a basic CanvasModulate as the fog of war, I get this: So I have a basic wall tile in my tileset which has an occluder covering the entire 32x32 tile. Anyway, I'm trying to use the a Light2D as the light source for the player character, with walls, floor, etc. ![]() I'm working on a basic tilemap-based 2d roguelike game. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |