godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.68k stars 20.11k forks source link

LightmapGI: Lightmap static lights are still counted in real-time light calculations #73289

Closed jcostello closed 11 months ago

jcostello commented 1 year ago

Godot version

v4.0.beta17.official [c40020513]

System information

Ubuntu with Nvidia 2060

Issue description

Lights statically baked are still count into light calculation. Shouldn't be disabled by default? Dinamic or not baked objects should be lighted by lightmaps probes (not working yet)

static light enabled image

static light disabled (Notice the FPS increase when disable it) image

Steps to reproduce

Bake a scene with static light enabled Disabled light See diference in FPS

Minimal reproduction project

No needed

Calinou commented 1 year ago

Dynamic objects are still lit in real-time by lights marked as static, so a performance impact is expected for static lights.

What we should do is add an option to make lights marked as static be fully baked into probes for dynamic object lighting. Currently, only their indirect lighting is baked – this option would make it so their direct light is also baked. This may warrant adding a fourth GI mode for lights such as "Fully Static", as this option may also be relevant for VoxelGI to a lesser extent.

This needs to be an option that is disabled by default, as direct light using probes is far less accurate than real-time lighting. You can't have precise shadows cast onto dynamic objects this way (the fully baked static mesh keeps casting shadows for other dynamic lights by design).

Calinou commented 11 months ago

I have a proof of concept: https://github.com/Calinou/godot/tree/light3d-add-static-baked-mode

Testing project: test_light3d_baked_static_mode.zip

It has some issues:

However, I was able to get a successful bake with lightmaps having the Static Baked lights present, yet dynamic objects not being lit by these lights in real-time at all.

Light3D bake modes from left to right: Disabled, Static, Dynamic, Static Baked. The white box is a static (baked) object, while the cyan torus is a dynamic object.

image

I'd appreciate help on this area as I'm not sure how to modify the lightmap probe baking code to get it to bake direct light for lights that use the Static Baked bake mode (and only those lights).

jcostello commented 11 months ago

In the future we have to come with a better name like: Dynamic, Mix / Movable (old static), Static

jcostello commented 11 months ago

I'd appreciate help on this area as I'm not sure how to modify the lightmap probe baking code to get it to bake direct light for lights that use the Static Baked bake mode (and only those lights).

It will be better to wait for https://github.com/godotengine/godot/pull/82068 to be merged first. Then maybe @DarioSamo can help you

Calinou commented 11 months ago

In the future we have to come with a better name like: Dynamic, Mix / Movable (old static), Static

Lights with Static bake mode that are moved or have their color/energy changed will not affect baked surfaces, so I think that bake mode should remain Static in the UI. In the UI, I would only add a distinction when it comes to lighting of dynamic objects by the static light.

Note that we can't rename the constant name in the enum either for compatibility reasons.

Calinou commented 11 months ago

Closing in favor of https://github.com/godotengine/godot-proposals/issues/8040, as feature proposals are now tracked on the Godot proposals repository.