Lighting performance

Hello, I want to inquire about performance optimization. I’m thinking of creating a custom lighting system because the one in GDevelop is very heavy. So, the lighting system I’ve come up with involves using matrices where each block would be an index in the matrix, and its tonality would be defined using a distance calculation from the light source of each index.

For example, the tonality would range from 255 to 0, and each object would assume the value of its index in the matrix. The matrix would also be updated with the brightness value (ambient light value + propagated light). I thought of this because I had an old phone, and when I added light objects, the FPS dropped significantly. I haven’t tested this system with a large number of objects yet, but it works.

My prototype was with effects, but it also lagged a lot, so just changing the tonality greatly improves performance. Has anyone done something similar?

1 Like

That sounds really interesting.

It’s a lot more elaborate and possibly a better of solution than what I would typically do… which is just use a texture to “fake” lighting onto the floor or background, and using no other lighting or very simple lighting for the floor or background otherwise - then if I need the characters lit, to use a normal or elaborate amount of lighting to light just the characters, in other words “going all out” for just the characters.

So the texture though… it provides a very close lighting to the floor or background. If I needed a foreground image, like total darkness surrounding an area around the character… I would probably use a texture for that too. The foreground texture would be a bit different and would just typically be something like all-black, with a transparent spot near the middle to be the more lighted area around the character. Then the foreground texture would be coded to follow the character.

If this isn’t exactly what you’re talking about though, I apologize… I’m just kind of talking about the things I sometimes do when I want to save performance when using a bunch of lights would zap performance.