laurenth-personal / lightmap-switching-tool

Tool that allows switching different baked lightmap sets on a unity scene at runtime.
MIT License
682 stars 90 forks source link

Is there any lightmap count limit ? #38

Closed JAMS49 closed 4 months ago

JAMS49 commented 4 months ago

Hi laurenth , I have just got a new hope to start my day night swapping journey in my commercial game project after I have found out your cool asset here,

I have tried swapping day and night lighting in little scenes , like there is only a hut and bunch of trees, works definitely well. But in my actual scene which is very big , it has total 229 lightmaps for day and 229 lightmaps for night, no resolution changed , everything is same just the light , but when I swap between the night and day , only the skyboxes of night and day scenes are changing , the night lightmap doesnt turn to day lightmap at all, like, When I switch , the morning sky shows up , but still it's darkness on the island ,, no daylight at all, I get no error messages , just the night lightmap stays forever no matter how many times I switch between day and night , I tried again with a simple scene , with the same method, there it works well, night days are swapped properly , but in my main scene ,, the lightmap isnt swapping at all, I baked the night last , and only the night lightmap is now in the scene and doesnt swap to day lightmap which I baked and stored at the first . is that a bug or something> like the total lightmap size of each day and night is around 4.5 gb , consists of 210 2k lightmaps, 15 1k lightmaps , 4x 512 lightmaps same for each scene, is there a limit for the lightmap swapper to do this action?

please help me out , Im totally stuck at this point

laurenth-personal commented 4 months ago

Hello, I don't know of any limit and I see nothing about that in the documentation, but maybe there is. Do you get the problem in the editor ? is there any error in the log ? It sounds like a lot of data to swap at the same time, and the tool doesn't have any logic to delay the swap for some of the light maps right now. It sounds like an interesting case but I don't think I can work on an update soon. Unity's Adaptive probe volume should support switching too nowadays, have you tried using it ?

JAMS49 commented 4 months ago

Hello, I don't know of any limit and I see nothing about that in the documentation, but maybe there is. Do you get the problem in the editor ? is there any error in the log ? It sounds like a lot of data to swap at the same time, and the tool doesn't have any logic to delay the swap for some of the light maps right now. It sounds like an interesting case but I don't think I can work on an update soon. Unity's Adaptive probe volume should support switching too nowadays, have you tried using it ?

thanks for the quick reply , but I fixed it somehow, I dont have idea about that error which says negative index or something like that , what I did is , drag and dropped lightmap data asset of the day scene in the baked lightmap tab , and then I clicked on the store button beside the day scene array , and now switching between day and night works well.

The main thing is when you wanna store a lightmap , just make sure that the lightmap data asset of that specific scene is currently assigned, then you can store it whenever you like. The asset is awesome, .

Btw, can you work on "blending" feature while swappng between lightmaps to prevent sudden pop up? i mean in the future at least? because Adaptive probe volume is only for the URP and HDRP since unity has got divorce from the built in RP

laurenth-personal commented 4 months ago

Blending would not be very efficient as the light maps are Texture2D and they are not compatible with Render Texture. This means that essentially I'd need to make a render texture to blend the 2 light maps, and each frame save the result to a texture 2D which is quite inefficient and usually leads to hiccups.

JAMS49 commented 4 months ago

Blending would not be very efficient as the light maps are Texture2D and they are not compatible with Render Texture. This means that essentially I'd need to make a render texture to blend the 2 light maps, and each frame save the result to a texture 2D which is quite inefficient and usually leads to hiccups.

I see, I think bledning the post processing would be a tricky way to prevent the pop up, whatever , Im sorry to knock here again, Now I switch between lightmaps, but the reflection data and light probes arent getting into the scene , I get this warning below:

Warning, error when trying to load lightprobes for scenario 0 UnityEngine.Debug:LogWarning (object) LevelLightmapData:LoadLightProbes (int) (at Library/PackageCache/com.laurenth.lightingtools-lightmapswitcher@2019.3.1/Runtime/LevelLightmapData.cs:194) LevelLightmapData/d__16:MoveNext () (at Library/PackageCache/com.laurenth.lightingtools-lightmapswitcher@2019.3.1/Runtime/LevelLightmapData.cs:122) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

is lightmap swapper failing to catch light probe index or something from the stored lightmap data?

do you know what could be wrong here? please help me out😓