0 votes

I am developing a 2D game for mobile/browser and want to add lights but they cause a significant amount of lag, is there any way to “bake” 2D lights or something similar?

Godot version 3.2.2 stable
in Engine by (25 points)

Note that Godot 3.2.2 is no longer supported: https://docs.godotengine.org/en/stable/about/release_policy.html

1 Answer

+1 vote
Best answer

First, to improve 2D lighting performance, try increasing the Scissor Area Threshold project setting above its default value (0.0).

Unlike 3D, there is no built-in way to bake lightmaps in 2D. There would be two ways to approach this from an editor plugin side:

  • Bake a texture that is overlaid with a CanvasItemMaterial set to the Multiply Blend mode.
  • Use Sprites with Add blend mode to represent light. If you don't need shadows, it's all you have to do. If you need shadows, you could have a plugin that creates Polygon2Ds depending on surrounding light occluders and renders them to a viewport which is modulated with a black transparent color.

Both of those approaches involve a significant amount of work when you need shadows.

Godot 4.0 will use a single-pass approach to 2D lighting, which is much faster when you use several lights that affect the same sprite.

by (12,869 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.