Saving of Realtime Lightmaps And loading on other scenes.

Hello ive been reading through the few forum posts and questions about realtime lightmaps and for global illumination, and even though i made quite the efforts through several scripts it always comes down to 1 small issue i cant seem to understand or find a way to tackle.

How do i find the size of the realtime lightmaps array / list and then re-abjust it.

The reason for that is cause per example for baked we would : Save renderer information and the index as well as the offset, and on load we would merely take all the pre-existing baked lightmaps, make a new array that is the size of both the pre-existing and the prefabs size and then set the lightmaps array to be the new array.

But i simply cant find a way to understand how to go with this for realtime lightmaps so i can move them across scenes yet not affect other already existing realtime lightmapped objects.

1 Like

Hi

Unfortunately you can’t really edit this since its a part of the LightingDataAsset. We are working on a new solution now for “realtime” GI and hopefully we will make it a bit more open.

Also, worth knowing. The realtime lightmaps doesn’t really exist like the baked one does. They are updated when they have to, and we actually generate them on the go when listing them in the UI (in 19.x of Unity). You can use reflection and use our internal API, LightmapVisualizationUtility.GetRealtimeGITextures(GITextureType textureType) which will give you a list of VisualisationGITexture (you are interested in the “texture” property on this struct). This is the method we use when listing them in the UI, but there’s no way of controlling the length of this array.

Hope this helped at all :slight_smile:

Infact due to my team realizing that we are rather limited for that approach we are instead trying to find a way to save and load light probe groups across scenes dynamically, cause we are making a procedurally generated game.
But after digging around i failed to find a way to add dynamically my own probes to the LightmapSettings.lightProbes my own probes in addition to the existing ones.

In continuation, i shifted my approach in having pre-generated probes then existing in a scene and moving them to their location once the room is generated, but there were 2 issue since we were trying to avoid baking in runtime :
1st ) Size of probes generated would have to be the maximum which would mean if the network was rebuild after movement there would be light leaks.
2nd ) You cant move probes around in runtime.

So i am a sitting duck here i am standing and trying to find anything i can use to create at the very least my own light probes, unless you can propose a better alternative.

Thank you for taking time to reply.

Hey neroid,

probes cannot be moved, but you can replace light probe SH values and make them look different. If you have a new room popping into existence, you could use the LightProbes.Tetrahedralize() API. Each room is its own scene and has its own LightProbes. Once you load that scene, you can call the API to merge the probes for the new room with the existing ones after you’ve replaced the SH values for the room. Would that solve your problem?

Cheers

In order for Tetrahedralize to work i would need to instantiate it as a scene, and even so i have no way of moving the whole additive root scene as a whole to fit my needs ( so i can move the baked probes as well since the room isnt in a fixed location ) (am i missing something?).

What i am making :

What i am making is a procedurally generated game, so i have some set of prefabs of rooms i want to add to not static positions based on the room creation positions. I managed to find a way to always keep track of each probes vector3 location and its SHL2 components, but the issue is clearly adding this to an existing scene. Since a room may be added after another i see no solution so far that does not involve rebaking.
Since i cant move or relocate the baked probes alongside the spawned room, and as such the room wont have any proper light, the room positions are not fixed thats why i am trying to find a way to move the probes.

So what i had in mind, and do correct my understanding if im wrong is :

Spawn a room at any given position with its probes ( currently the light probe group is attached as a child for this purpose, but ofcourse this doesnt add the baked probes anywhere ).

In short :

Is there a way for me to dynamically spawn rooms at any position and relocate baked probes or without baking make probes and add them on the existing baked probes, or as a last proposal atleast a way for me to bake a specific probe group only? If im missing anything feel free to inform me on what i may have gotten wrong or missed.