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
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.
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
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.
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.
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!
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
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 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?
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?
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?
Dear Laurenth,
would you be able to implement the support of reflection probes?
They do not switch together with the lightning scenarios.
Best, Friedemann
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.
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!
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?
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?
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:
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.
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)
Any chance to have a blending feature between lighting scenario, not full switch but controllable crossfade between 2 scenario?
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, 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!
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!
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.