Giter Site home page Giter Site logo

laurenth-personal / lightmap-switching-tool Goto Github PK

View Code? Open in Web Editor NEW
653.0 41.0 88.0 19.76 MB

Tool that allows switching different baked lightmap sets on a unity scene at runtime.

License: MIT License

C# 100.00%
unity lighting lightmap unity3d

lightmap-switching-tool's People

Contributors

bian-sh avatar laurenth-personal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightmap-switching-tool's Issues

Can't use the same lighting scene on 2 different static geometry scenes.

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.

Error message upon hitting play that 2nd lighting cannot be loaded as it is not in build settings

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

Lightmap Static Batching Issue

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.

LightProbes not changing

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.

Still supported in 2021?

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

Failed to build.

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)

Support Asset bundle workflow

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?

Dynamic to Baked Lighting Switch

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?

Have built and stored the lightmaps, but now cannot actually swap them

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?

Support of reflection probes?

Dear Laurenth,

would you be able to implement the support of reflection probes?
They do not switch together with the lightning scenarios.

Best, Friedemann

Static Geometry lightmaps missing

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.

Improve documentation

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!

Error when trying to load lightprobes for scenario

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?

Incorrect results while using lights that don't have direct lighting baked

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?

Problem with light probes

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:

  1. Main scene with static objects, 1 dynamic object and lighprobes. Lightmode is Subtractive.
  2. Scene 2 with mixed directional light. Lightmode is Subtractive.
  3. Scene 3 with mixed directional light. Lightmode is Subtractive.
    I did everything that you wrote for setup. Light probes don't change if I try to change a scenario. It look the same as last baked result.
    How I can fix that? Thanks.

Unable to load lightmaps in Build; working fine in Editor

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.

C# Script to Call Function to Switch Lighting

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)

Cannot implicitly convert type `UnityEngine.Coroutine' to `Coroutine'

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

Workaround for Build and Store

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.