godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add support for using pre-baked lightmaps in LightmapGI #11116

Open CycloneRing opened 4 days ago

CycloneRing commented 4 days ago

Describe the project you are working on

Some Platform Design

Describe the problem or limitation you are having in your project

Godot has a good lightmapper which is good for many usecases however there is a limitation when you want to go more accurate. Most 3D Software has lightmap baking tools but after many attempts I couldn't use my pre-baked lightmaps. My mesh has already a UV2 mapping channel and my pre-baked lightmaps are EXR files. image image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

We need a way to prevent Godot of packing baked lightmaps and keep the current UV2. In Godot Editor I can see the original UV2 image But this is what happens after bake image

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Maybe a custom LightmapGI node or a way to add custom lightmaps per mesh.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can't. I'm not sure if already this is possible or not but after 2 days of search I couldn't find anything.

Is there a reason why this should be core and not an add-on in the asset library?

Yes. It's a core feature.

Expected result should look like this : image

Calinou commented 4 days ago

One difficulty with using pre-baked lightmaps is that you still need to bake LightmapProbes somehow (for dynamic object lighting). There is no standard file format for this. If you only have a way to load the lightmaps into a LightmapGIData resource, you won't have working dynamic object lighting.

however there is a limitation when you want to go more accurate.

Can you describe some of the limitations that can't be circumvented by adjusting settings in LightmapGI (such as quality or texel density)?

There are good use cases for baking lightmaps on scenes with pre-made UV2 (as this can reduce seams or light leaking), but you don't need to bake lightmaps outside Godot for that.

CycloneRing commented 4 days ago

@Calinou Yes, For example Caustics, Dispersion Refraction, Advanced Shadows (V-Ray) etc. LighmapProbes can be easily solved by assigning prebaked lightmap to Mesh as emission on UV2 and then bake probes. image

Result : image

yosoyfreeman commented 3 days ago

I think this would make sense. There are a few incredibly powerful solutions for creating lightmaps externally and that could help a lot for the ones who want to push things a little farther (Say, you could do the final bake for release in blender at maximum quality)

jcostello commented 2 days ago

@Calinou Yes, For example Caustics, Dispersion Refraction, Advanced Shadows (V-Ray) etc. LighmapProbes can be easily solved by assigning prebaked lightmap to Mesh as emission on UV2 and then bake probes

How did you bake probes only?