Ayfel / PrefabLightmapping

Script for saving lightmapping data to prefabs. Used through the Assets tab in Unity. Place your prefbas in the scene with this script at the root. Set up your lighting and in the editor go to Assets->Bake Prefab Lightmaps. After is processed you can now spawn your prefabs in different scenes and they will use the lightmapping from the original scene.
645 stars 90 forks source link

Clarification of Light Probes #50

Closed FalseP closed 2 years ago

FalseP commented 2 years ago

This stuff is a godsend for procedural devs but I would like some clarification on the light probes.

When you say "create a uniform light probe group in the scene you are going to instantiate prefabs at" do the light probe groups really have to be perfectly uniform?

Also, since they have to already be in the scene itself, and not within the prefabs, how would we fine tune where they end up once the prefabs instantiate (i.e. preventing them from being in walls, getting them to be in crucial areas where the light changes substantially)?

Ayfel commented 2 years ago

Yes, clearly thats a limitation, you can do more complicated setups (and it depends in the procedural setup and spatial configurations you use) but where I have gotten good results has been with those uniformly spaced configurations, even when a probe fell somewhere I didnt want it, in general it wasn't a big issue. To clarify, you can do whatever configurations of probes you want though. You will not get perfect, but all the use cases I have seen have been pretty good overall.

FalseP commented 2 years ago

Ok, thank you very much for the clarification. So to confirm: the only mandatory requirement is that the light probes must be in a scene and then have an empty bake done, with uniform groups giving the bets results?

If the above is true have you thought of adding an option to have the probes placed in the prefabs instead? I'm very surprised unity has nothing like this and think that this should have much more attention.

Ayfel commented 2 years ago

It is a known issue and the calculation that is done at bake time is not available at runtime so thats the reason the light probes won't help being inside a prefab.

And yes only requirement is probes and empty bake.

Ayfel commented 2 years ago

Some literature worth looking at https://forum.unity.com/threads/any-runtime-dynamic-baking-options-or-are-any-coming.821676/#post-5612233

From a Unity dev:

"There could be something worth considering, depending on the type of game you're building. What Unity allows you to do is update the SH coefficients of light probes at run time. However, you cannot update the positions of probes. What this means is that if you know beforehand the size of a scene, you could flood fill it with probes in the editor and bake them, so the positions and tetrahedralization are precalculated and saved with the scene. By default you could just bake the ambient probe into all probes."