godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add a free-form Light2D node #11005

Open CEHAGA9 opened 1 month ago

CEHAGA9 commented 1 month ago

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:

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:

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:

Example control interface:

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.

CarpenterBlue commented 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.

girng commented 3 weeks ago

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?

CarpenterBlue commented 3 weeks ago

no, that is different thing. That is light blocking. Freeform light looks like this.

girng commented 3 weeks ago

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