Redot-Engine / redot-engine

Redot Engine – Multi-platform 2D and 3D game engine
https://redotengine.org/
MIT License
4.68k stars 205 forks source link

Expose runtime baking functionality in LightmapGI #8

Open sourcelocation opened 1 month ago

sourcelocation commented 1 month ago

Hi ReDot community 👋

This PR implements .bake() for script usage on LightmapGI.

Implementation notes:

Demo video:

https://github.com/user-attachments/assets/542a1b5e-07b9-4b0d-a7df-668516359543

Project for testing: https://github.com/sourcelocation/lightmapruntimebakingtest/

Originally made for Godot, but their latest decision lead me to contribute to ReDot instead.

Capewearer commented 1 month ago

By the way, could it be used except the case for procedurally generated levels? Like the way to calculate rarely changing dynamic lighting for breakable light sources? E.g. Thief clone, but you have many lights that give indirect lighting, and when one of sources is broken, a lightmap for small part of level is rebaked. Basically raytracing, but at slow speeds.

sourcelocation commented 1 month ago

@Capewearer I don't see a reason why not! I'm personally already using it for user generated content, and it works perfectly.

TheRektafire commented 1 month ago

While we're at it, how hard would it be to add a way to overlay dynamic lights onto a lightmapGI'd surface? Specifically one that's been baked using the "all" bake mode? There are other engines that can mix static baked lighting with dynamic lights (mostly older ones from back when that was more necessary) so it would be nice to mix dynamic direct lighting and static baked lighting in godot as well. Currently I'm pretty sure you can only mix the two if no lights in the scene are set to bake all

sourcelocation commented 3 weeks ago

Still no merge?

Spartan322 commented 3 weeks ago

We've been a little busy with the rebranding and preparing a 4.3 release, while I would prefer to try sending PRs upstream to Godot first and see if it languishes or is rejected first, if you feel you don't want to submit anything to Godot in that case, then we'll see about implementing it and minimizing the chance of merge conflicts when we merge the master branch from Godot.

sourcelocation commented 3 weeks ago

Awesome. The latter option sounds way better to me 👍