Realisitic light cones

Godot Version

4.4

Question

Hello, I’m working on a 2D stealth game and am prototyping light. I want to achieve a realistic flashlight effect where dark areas are enlightened by the flashlight but lighter areas aren’t. For the dark areas I’m currently using a PointLight2D with Subtract blend mode and for the flashlight I use a PointLight2D with blend mode set to Add.
This picture describes the situation better:

Do you know how to achieve this effect?

the docs have a very clear and easy to follow tutorial on dynamic shadows and lighting

you need a canvasmodulate to cover the screen that will make everything dark.
you can place your light areas over this and use a different layer to make them not be affected by the specific light.
occluders are used to create shadows.
for 3D effects you need a normal map, which you can make from the silhouette of a sprite by applying a bump effect and then normal map filter. or you can bake a 3D mesh. normal maps and all maps should go on a canvasLayer (instead of image), and that has slots for images.

for a flashlight I would create an image that’s a spherical gradient and cut it in the shape of a triangle from the center, like a slice of pizza. and then trim it.

1 Like

I’m familiar with all these concepts. My issue was that light should only appear in the areas where I use a negative light to create the dark effect.

Meanwhile, I fixed it by using separate floor objects for the light and dark areas. Then I can use different light masks for each floor sprite in order to allow the flashlight or not.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.