Open CEHAGA9 opened 1 month ago
Yes, this is absolutely needed. 2D lighting system in Godot has much to be desired and feels undercooked. Among many other issues, it lacks ability to create localized dark areas as well. This proposal and it's counterpart of masked CanvasModulate are needed to match artistic potential of other engines.
doesn't the light occluder let you make polygons/any shape? https://youtu.be/DAIUg3wql_E?t=252 (timestamped)
or are you talking about the quality/way it's rendering the lights?
no, that is different thing. That is light blocking. Freeform light looks like this.
no, that is different thing. That is light blocking. Freeform light looks like this.
ohh. ty for that. interesting. pretty sure i've seen someone do this on godot already (with masking/canvasmodulate and polygon tool). i'll take a whack at it and edit my post
Describe the project you are working on
Currently, I am working on a Celeste-style 2D game set in caves and forests using Godot 4.3, and one of the key visual elements involves complex lighting setups to create immersive environments.
Describe the problem or limitation you are having in your project
In the current state of Godot's 2D lighting system, the available light nodes (such as Light2D) offer limited options for manipulating light shapes. Light is mostly constrained to simple forms like circles or textures, and while masks can be applied, they lack the intuitive flexibility needed for more complex lighting effects. Without a tool similar to Unity's Free Form Light, creating intricate or irregular lighting sources (such as simulating light coming through uneven surfaces, or creating lights that match specific object contours) becomes time-consuming and cumbersome.
This limitation makes it difficult to achieve certain dynamic visual effects, especially in environments where irregular lighting is key to the scene. For example:
Custom shapes for torches, windows, or other light sources with non-standard shapes are difficult to achieve.
Light transition effects that smoothly follow custom shapes are either not possible or require significant time investment.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
I propose the addition of a Free Form Light 2D node, inspired by the implementation in Unity. This node would allow developers to:
Create and customize 2D lights with free-form shapes using control points (similar to vector shape creation).
Adjust the light's shape in a more intuitive and flexible way, making it easier to craft dynamic and immersive lighting in 2D games.
Integrate with existing lighting systems, allowing for more advanced use cases, such as animated light shapes, deformable lights, or lights that adjust dynamically based on game interactions.
This node would significantly streamline the process of creating unique light effects in 2D games, reducing the reliance on workarounds and manual manipulation of light textures or shaders.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The Free Form Light 2D node could function similarly to Unity's equivalent by providing control points that the user can place and move around, forming a custom light shape. Here’s a general workflow and feature set:
Users create a Free Form Light 2D node in the scene.
Control points appear around the light, which can be adjusted to form custom shapes. The light's intensity, color, and falloff would follow these shapes, allowing users to control the light’s behavior in a dynamic and flexible way.
The light would blend with other lights in the scene and cast shadows like any other light node.
Example control interface:
A set of draggable points that control the shape of the light.
Additional options for adjusting light softness, falloff, and shadow intensity based on the shape.
Example Use Case For a scene where light comes through a broken window, a developer could use the Free Form Light 2D node to trace the window's irregular shape, making the light source realistic and closely matching the environment.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Currently, this feature cannot be easily worked around with scripts. Achieving similar results would require extensive use of shaders, manually shaped light textures, or custom systems that lack the flexibility or ease of use that a dedicated Free Form Light 2D node could offer.
Is there a reason why this should be core and not an add-on in the asset library?
Lighting is a fundamental aspect of visual design in 2D games, and having an intuitive, flexible lighting tool like Free Form Light 2D would benefit a wide range of users and projects. Since other light types are already integrated into the engine, this enhancement would fit naturally into Godot's core feature set, providing a more complete and robust 2D lighting system.