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:
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.
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.