Replies: 7 comments 9 replies
-
I'm also having this problem and i require it to be fixed to procced with the game i'm making. Which i intend to open a steam page for soon. So a fix for this would be very much appreciated. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, the way 2D light rendering works makes it impossible to expose this as a project setting. The number has to be hardcoded for reasons similar to the number of 3D lights per mesh in the Mobile rendering method. This is done to ensure the shader can run as fast as possible (since it targets mobile devices), and because a shader that caters to a high light count would suffer from excessively slow shader compilation times (web browsers often struggle with this). The constant that defines the maximum number of lights that can affect a given CanvasItem is defined here:
However, you can't just increase this constant and expect lighting to still work correctly (I've tried just in case 😉). I suggest looking into an alternative solution instead:
|
Beta Was this translation helpful? Give feedback.
-
Would it be infeasible to support an alternative rendering pipeline that is identical to the existing Forward/Mobile pipeline except for supporting an increased amount of lights? Alternatively, code generation could be used to change the values in the text files necessary for compilation to match the exposed project setting. Will be quite unfortunate if there is no workaround though. |
Beta Was this translation helpful? Give feedback.
-
It would be great to have a commit available that increases the cap so that it could be cherry picked for custom builds. That would probably be sufficient to solve this issue. |
Beta Was this translation helpful? Give feedback.
-
Also IDK if I just suck at testing this, but by my count in editor the cap is 15, not 16. |
Beta Was this translation helpful? Give feedback.
-
OK after working on this problem for awhile in my own project, I have some findings & thoughts to help other people encountering this problem:
|
Beta Was this translation helpful? Give feedback.
-
Also an idea for improving this for the average user (I have little rendering experience, so someone please tell me if this won't work): Godot could combine non-overlapping light textures into one and pass them as a single light to the shader. Shadow information would have to be combined & embedded into a separate texture too. This should change the limit to only apply to overlapping lights, which would be a heck of a lot more practical. Nobody's going to care if lighting breaks down a bit when there are 16 overlapping lights. Heck, at that point you could probably reduce the light limit to 8 or so. Also, if using that approach, instead of just not rendering the lights that can't fit in the buffer, you could still stitch them into the buffered textures, just overwriting any other lights at the same location. That could mean it would only be the overlapping portion that doesn't get rendered. Which, again, if there's that many lights overlapping, probably isn't a big deal at all. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the project you are working on
A top-down 2D roguelite that makes heavy use of the 2D lighting system and shadows to drive its art style.
Describe the problem or limitation you are having in your project
During my project, I am constantly encountering issues with rendering related to the 16 light cap. Any time more than 16 light sprites intersect an area (even if most of them are occluded by the environment), disruptive visual artifacts appear that can draw the player's attention and disrupt the desired visuals.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
If the light limit was increased to a higher number, these visual artifacts would not occur and gameplay would not be significantly disrupted.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The current limit appears to be hard-coded into Godot's default shaders. A fix would involve increasing the light limit constants and increasing the amount of space allocated in shader uniforms for light data to be sent. If possible, this should be a modifiable parameter (reducing shader space allocation for projects that do not benefit from this change), but that may prove difficult.
If this enhancement will not be used often, can it be worked around with a few lines of script?
It is possible to work around this issue by replacing lights with additive sprites when shadows are unlikely to be relevant to the object, mitigating the risks. However, if a project has a significant quantity of moving or moveable lights, this will quickly become prohibitive, as unless every possible situation where 16 or more lights could overlap is accounted for, there will be disruptive visual artifacts.
Is there a reason why this should be core and not an add-on in the asset library?
The fix requires a change to core shader code, which cannot be modified by an addon.
Beta Was this translation helpful? Give feedback.
All reactions