laurenth-personal / lightmap-switching-tool Goto Github PK
View Code? Open in Web Editor NEWTool that allows switching different baked lightmap sets on a unity scene at runtime.
License: MIT License
Tool that allows switching different baked lightmap sets on a unity scene at runtime.
License: MIT License
Apologies if this is not the right place to ask -- your lightmap-switching tool looks really interesting, I've been reviewing the code to understand how it works. By the looks of things the switch between light maps is sudden? I've not tested it yet, but the change would be sudden and incur a performance hit on larger / multiple changing / loading of maps?
I'm trying to find a smooth solution to go from a non-baked daytime scene (single dynamic light-source), that transitions to night-time and switch the lighting and maps at night to a baked configuration. I've actually got this working already (kind of), but the main issue I'm encountering is that when the light maps change there is a frame hitch so it's noticeable.
Ideally there would be someway to smoothly transition from one lighting configuration to the other. Do you have any thoughts on this kind of use-case?
The lightmaps will be named after the lighting scenario scene, thus you can't currently use the same lighting scenario on more than one scene.
A workaround is to duplicate the lighting scenario and give it a new name, but you can't use lighting scenarios as lighting presets currently.
In your example project you have StaticGeometry folder with pre-baked maps, but in your instructions you don't mention when I suppsoe to bake the Static Geometry scene. I wasn't able to reproduce map switching becouse I don't know at what step I am suppose to bake the static geometry scene.
Dear Laurenth,
would you be able to implement the support of reflection probes?
They do not switch together with the lightning scenarios.
Best, Friedemann
Hi, i am having issues with the use of lightprobes.
The way i understood, is that the light probe groups have to be contained in the main scene with the static geometry.
However after i build and store a scenario and entering play mode, the scenario isn't correctly loaded and errors pops up in the console.
What exactly is the workflow related to lightprobes?
Good day! I'm getting this error when trying to build the scene:
LightsBakingSettings.cs(15,14): error CS1061: Type UnityEngine.Light' does not contain a definition for
lightmapBakeType' and no extension method lightmapBakeType' of type
UnityEngine.Light' could be found.
How to get around this issue?
(Unity 2017.3.0f3)
Hi there!
I've stumbled upon this repository and it is quite useful! Are you happy for this to be re-used in a product for commercial purposes?
If you are happy for us to use as is, could you possibly add a MIT license to the repository?
Here's a reference: https://help.github.com/articles/adding-a-license-to-a-repository/#including-an-open-source-license-in-your-repository
And a reference for an MIT license: https://choosealicense.com/licenses/mit/
Thanks!
Followed the steps as mentioned in the readme.
However upon hitting play an error is thrown that says: Scene 'Lighting_02' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
To add a scene to the build settings use the menu File->Build Settings...
I have correctly stored the lighting as when I change default lighting scenario on the lightswitcher script it does default to either lighting scenario 1 or 2 depending upon the setting
First of all: thanks, this is a great tool :)
Scond: I added the same lightprobe group to the Light and Dark scenes (without geometry) and disabled it in the geometry scene. For some reason my lightprobes are always black but the lightmaps are changing fine.
Hello,
I am using your Lightmap Tool because Unity doesn't utilize Culling Masks when it comes to baking GI.
My Scenario using your Litemap Switching Tool:
I am using one single scene to hold both indoor and outdoor environments. My player is outside part of the game and can enter caves and then exit again to the same outdoor environment. When player is outdoors I load the outdoor lightmaps and when in caves I load the cave lighting Lightmaps.
Here is where I run into problems. I am using static batching because this game is for mobile and I am trying to optimize it. Static batching is interfering with your lightmap tool. The UV2 cordinates get out of whack. But if I don't static batch it works great.
Here is how I am baking my scene.
I am baking the lightmaps in sections so I end up with two sets of lightmaps. Outdoor and Cave.
I don't need cave lighting lightmaps on my outdoor enviroment so when I bake the cave lighting I turn off all outdoor game objects and then bake(so only cave gameobjecst are baked). I then bake the same for the outdoor gameobjects and turn off all cave gameobjects. If I didn't do this my amount of lightmaps would double for lightmaps that will never be seen.
So I now have two set of lightmaps. Outdoor and Cave.
For whatever reason when Static Batching is On the outdoor lightmaps UV2 coordinates are not correct. But the cave UV2 coordinates seem to be fine.
My outdoor enviroment is much larger than the cave enviroment. Don't know if that is causing an issue?
Thanks for any help.
Any chance to have a blending feature between lighting scenario, not full switch but controllable crossfade between 2 scenario?
Hi Laurenth,
I have built couple of scenes and baked as per steps provided. They seem to work fine in the Editor. However, when I build the project and test the same, lightmaps are not being loaded while switching from one scene to another.
So I have checked out that I can manually bake the lightmap in the scene and then store it using the lightmap switcher , when I switch it to day and night , I have scene that it actually replace the lightmap.data asset of the empty day scene on the baked lightmap tab . are those lightmap.data asset which are assigned automatically when switching between day and night are alone enough to properly arrange the lightmaps of the scene? because I have a large scene , I baked it and it's lightmap.data asset (before i've stored the bake info into another scene) is sooo large , like 370 mb or something , which causes crash in mobile for being too big . can I get rid of it somehow?
Thank you very much for this tool.
My requirements were different to your use case so I did things differently. I needed the same lighting conditions but with a dynamic map. I outlined my steps and the outcome on the Unity forum:
https://forum.unity3d.com/threads/doom-e1m1.488128/
It would be great if this could be incorporated into your instructions, and maybe also your thinking for future development
Hi, this tool looks great =- just what a lot of people need I think!
Its all set up for me apart from the last step ("Now add an empty Gameobject to your scene and add a LightingScenarioSwitcher for previewing the switch").
I don't see anyway to add that component/script?
Beyond that switch UI, what is the method to be called to programmatically swap the lightmaps?
I have a few questions that I think should fall under the improve documentation category.
Can I also add non.static object in the master scene? On the sample scenes there's non-static objects on the main scene, so I guess you can put everything there, right?
I shouldn't bake lightning there either it either right? So the first one should be the fallback one? Should I select that in unity's official baked lightmaps or don't touch that?
If I have a mixed or baked light that is common to every scene, it should be on the master scene as well?
I think that's all for now, thank you for this tool!
I know this is a dumb question, but I can't seem to get this to work. What is the C# script to call a baked lightmap?
Instructions say "Call the public method LoadLightingScenario using an integer argument that represents the index of the lighting scenario"
I am not understanding how to achieve this, as I am trying the following:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SC1 : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
LevelLightmapData.LoadLightingScenario(1);
}
}
I was able to get the rest of this working, I was able to add new scenes, and now I just need them to change upon collision with the script above. Thank you, and again, and I apologize for this dumb question. I know it is going to be something simple. (And I did search existing tickets/readme here and found nothing)
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
Hello, thank you for the great tool. I have a problem with light probes. It don't change if a scenario is changed. It take values from last baked data of the main scene.
Unity version 2019.4.16f1. I have in my project:
Scenes:
I have two different scenes in my project. The same scene with Day and Night modes. Now, I have placed static geometry in a Scene and created two Lighting scenes.
Lighting Scene 1: It has the below properties
Light Type : Baked
SkyBox : Skybox_Day
Lightmap Parameters: Day_Params
Lighting Scene 2: It has the below properties
Light Type : Mixed
SkyBox : Skybox_Night
Lightmap Parameters: Night_Params
These two scenes look different when playing them using lightmap switching tool when compared to playing them individually. Baked Light Scene looks almost similar in both cases, but Mixed Light Scene is completely different. I tried loading the Lighting Scenes in both the cases to be on the safe side, but issue persists.
I have followed the exact same procedure in ReadMe. What I am doing wrong here?
Hi, I am using Unity 2017.2.0f3 and the lightmaps are messed up after baking. I see this comment:
The "Build" and the "Store" steps have not been merged because in some builds ( seen in 5.5.0f1 ) the lightmaps don't load correctly after baking
I have a few lightmaps set up for a particular scene so I modified the script to build and store them all overnight. Is there a workaround to this existing issue? I've tired something like this:
Debug.Log("Building Lights: " + ScenarioName);
yield return BuildLightingAsync(ScenarioName);
EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath(BaseScenePath + "/" + ScenarioName + ".unity"), true);
Debug.Log("Enter Play Mode");
EditorApplication.ExecuteMenuItem("Edit/Play");
///////// The below code doesn't get executed anymore once Play mode starts. Workarounds?
Debug.Log("Waiting 30 seconds");
yield return new WaitForSeconds(30);
Debug.Log("Exit Play Mode");
EditorApplication.ExecuteMenuItem("Edit/Play");
Debug.Log("Storing Light");
StoreLightmapInfos(storeIndex);
Thanks!
Hey Laurenth,
sorry to bother but I get this error when importing the LevelLightmapData-script into my project:
Assets/LevelLightmapData.cs(73,38): error CS0029: Cannot implicitly convert type UnityEngine.Coroutine' to
Coroutine'
Any idea why this is? Didn't change a thing and in a fresh testproject it is working, too.
I am working on 2018.2.2f1
Thank you in advance for any help and best,
Friedemann
Hi and thanks for this tool :)
I'm experiencing an issue with light probes. I follow all the instructions, BUT, I do not build the app with the scenes inside, I make asset bundles instead and download them via the internet through the app. So, in the asset bundle, I include the "master" scene only (so, not the "day" n "night" scenes). The lightmaps are correctly included, but the LightingData assets are not.
I think here's the problem with the light probes. Do you think is there some way to link these assets in the master scene?
Hi!
So, this tool looked promising, and seemed to do what it should. However, when I bake the 2nd and 3rd lighting scene in your example map, then unity will remove the existing lightmap data for the static scene, and move the reference to the last baked lighting scene. So, I end up with lighting 1 and 2 pointing to data located in lighting 3. So, when I rebake your example scene, I get Lightmap-1_xxx only in the last bake (lighting 3) Is this a new behavour from unity that breaks your script?
I also get a warning on "Store", where it's recommended to instantiate a scriptable object instead of creating a new.
Do you have any solutions? Thanks!
Kjetil
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.