I’m thinking about making a character entirely out of Polygon2D nodes without textures. One thing I haven’t figured out how to do is make each polygon cast a “permanent” shadow on top of the ones that are Z levels below it.
Below is an image of what I want to do, but using shaders/lights. I’ve only managed to do this by making extra polygons to fill in as the shadows.
How exactly do I have to set up a light source to achieve this effect? Using a DirectionalLight2D or a PointLight2D just brightens the polygons and I can’t figure how to use a LightOccluder2D, or even if this is the correct way to get this result
(The polygons are green due to the DirectionalLight being green) - The occlusion simply applies the shadow on anything that is Z levels below it.
Are you set on using light sources, or would you be okay with a shader that just creates the shadows without checking for specific light sources? It looks like this might do what you want, but you might need to modify it to work with your exact use case (multiple z levels).
Generally it seems like some kind of shader might be your best option, it seems like the 2d lights are intended for casting lights within a given z level rather than between them. If you want more complex shadows across multiple z levels, you might need to create your own light objects (just a position, color, and intensity) and pass them to a shader that does something similar to the linked example, but modified based on your lights list.
It’s possible there’s a simpler way that someone else could chime in with (I’m pretty new to godot), but as far as I can tell the built in 2d light and shadow systems aren’t designed for different z levels, so you’d need to use something else.
That’s exactly the kind of thing that I need, just a shame I need to have a texture on the polygon and, code as is, it offsets the texture a lot compared to the polygon’s center. While not “ideal”, I can probably work with this, though creating anything other than squares will be quite a pain if I don’t use large textures, due to the zoom level of Godot’s UV editor
I’ll mess around and see if I can get it to work as I want until a more definitive solution shows up, thanks!