# Quick Start

{% hint style="danger" %}
**Please note that the asset has two different versions**.&#x20;

[**Lite** ](https://assetstore.unity.com/packages/tools/utilities/magic-lightmap-switcher-built-in-rp-192332)version which only supports **Built-In RP** and [**Pro** ](https://assetstore.unity.com/packages/slug/196489)version which supports **Built-In + URP + HDRP**.&#x20;

The manual is identical for both versions.
{% endhint %}

{% hint style="info" %}
Before proceeding with the next steps, please read the instructions in the "[General Settings](https://motiongamesstudio.gitbook.io/magic-lightmap-switcher/getting-started/general-settings)" section. This is a necessary step before using the plugin.

If you have purchased a version for the built-in rendering pipeline, then a set of test scenes is available for you in the **Magic Lightmap Switcher** ➞ **Examples** ➞ **Scenes** folder.&#x20;

If you have purchased the version for SRP, then before proceeding you need to import one of the SRP support packages (URP or HDRP). It's available in the **Magic Lightmap Switcher** ➞ **Support Packages** folder. Import the package you need, after that the corresponding scene will be available in the **Magic Lightmap Switcher** ➞ **Examples** ➞ **Scenes** folder.
{% endhint %}

## 1. Adding An Instance

Go to **Magic Lightmap Switcher** ➞ **Examples** ➞ **Scenes** folder and open the **Quick Start** scene.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MXh2j5ZJdIhywR5nbJJ%2F-MXhEAEZ4I-5dv1akn5R%2Fimage.png?alt=media\&token=62d32fb6-5286-4c29-bc1a-33a863b7c36a)

Go to the editor menu **Tools** ➞ **Magic Tools** ➞ **Magic Ligtmap Switcher** ➞ **MLS Manager**

After selecting a menu item, the dockable [**MLS Manager**](https://motiongamesstudio.gitbook.io/magic-lightmap-switcher/system-components/mls-manager-window) window will open. You can move it to a place convenient for you.

{% hint style="info" %}
Scene must contain an instance of the **Magic Lightmap Switcher**. This is necessary for the plugin to process scene objects.
{% endhint %}

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MW4dM3biInmIqjF3Pvd%2F-MW4oi9SzoBiDnah3Xb8%2Fimage.png?alt=media\&token=4244fb36-c5a4-43fe-95fa-a21e158925dc)

Click the "**Add Instance**" button, the **Magic Lightmap Switcher** object will be added to the scene in the "**Magic Tools**" group of objects (if there is no such object on the scene, it will be automatically created)

The manager window will look like this.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MYkJhEaTi0QbsWj8Z9W%2F-MYlALhJ9VEiE7AlKS6U%2Fimage.png?alt=media\&token=f87dea6a-d234-4335-8d04-62dbf61ed4c6)

## 2. Creating Presets

Now you can prepare some lighting presets for your scene and save it. Click the "**Create New\..."** button to create a new preset. The preset manager window will open automatically.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-McoIurVDW4lwLZg2FNZ%2F-McoJNjNfeMnLFfbCIFH%2Fimage.png?alt=media\&token=017ee077-368b-4174-8295-7f8bff5c70b1)

{% hint style="info" %}
You can name the presets whatever you like. These names will then be used to display the saved lightmaps.
{% endhint %}

Click on the light source, it is in the **"Scene Lights"** object in hierarchy. After that, the **"No Selected Lights"** button in the **"Light Sources"** category of the manager will change to **"Add Selected Light"**. Click on it.

{% hint style="info" %}
You can also select multiple lights and add them with one click, if needed.
{% endhint %}

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-McoIurVDW4lwLZg2FNZ%2F-McoOQoZXq4dltkKR-Ej%2Fimage.png?alt=media\&token=f825f75b-505e-4f0d-9e45-0b29ecb16001)

The light source will be added to the list and you will have access to editing its main properties. To simplify the example, we will only change the rotation of the light source to simulate the movement of the sun across the sky.

Change the **Rotation** values ​​like this: **X**: 20; **Y**: -30; **Z**: 0

The settings will be automatically saved. Now press the **"Duplicate And Edit"** button - the preset will be duplicated.&#x20;

Change the **Rotation** values ​​like this: **X**: 20; **Y**: -90; **Z**: 0

Repeat the action and change the values ​​like this: **X**: 20; **Y**: -150; **Z**: 0

{% hint style="info" %}
You can also edit light source directly from the scene. Any changes you make will be automatically saved by the preset manager. However, this only works while the manager window is open and the appropriate preset is selected.
{% endhint %}

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MYkJhEaTi0QbsWj8Z9W%2F-MYlEfXWllJMIWaZyZYx%2Fimage.png?alt=media\&token=2d74bfd7-86c3-4b9c-b5ef-d37bb5357fd9)

Now you have three presets, you can switch between them and edit them.

## 3. Baking

Change the "**Storing Mode**" to "**Queue**", check the "**Create Lightmap Scenario**" option and click the "**Bake and And Store Lightmaps Queue**" button. This will start the automatic process of baking and storing the lightmaps for all added presets.

<figure><img src="https://484743511-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-ML4jBQpiY0hXPLy-BzC%2Fuploads%2F9vA9XYDcNSk33Ndksh67%2Fimage.png?alt=media&#x26;token=74996bcb-efc6-4b15-87c9-0de4f934b21a" alt=""><figcaption></figcaption></figure>

When baking is complete, all saved lightmaps will be displayed in the manager window, and the scene will be lit by the first stored lightmap.

<figure><img src="https://484743511-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-ML4jBQpiY0hXPLy-BzC%2Fuploads%2FpWIOzl47EiZXRGVndZs2%2Fimage.png?alt=media&#x26;token=3f29ee0e-f026-456a-b578-c91458f218a6" alt=""><figcaption></figcaption></figure>

## 4. Testing The Scenario

{% hint style="info" %}
**Lightmap Scenario** will be created automatically only if you have checked the "**Create Lightmap Scenario**" option, if the option is not checked, then you need to do it [manually](https://motiongamesstudio.gitbook.io/magic-lightmap-switcher/system-components/mls-manager-window#switching-blending-tab).
{% endhint %}

### 4.1 Lightmap Switching

If you have not completed the shader patch, then initially the scenario interface will look like this for you.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MiwRcMZ_hrubFzB_HGg%2F-MiwSmQF7cuSSrEUs2qM%2Fimage.png?alt=media\&token=9b3fb213-974c-433b-893c-570396930a1f)

You can patch shaders using **Tools ➞ Magic Tools ➞ Magic Lightmap Switcher ➞ Prepare Shaders...** or continue working in lightmap switching only mode.&#x20;

If you click the "**Use Switching Only**" button, the script interface will change as follows.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MiwRcMZ_hrubFzB_HGg%2F-MiwW5PMha3LcB0-2gVF%2Fimage.png?alt=media\&token=4f31c4f1-0eae-4161-8772-faba158a1a25)

You can now switch between baked lightmaps. To test this, click one of the "**Load**" buttons in the "**Blendable Lightmaps Queue**".

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MiwRcMZ_hrubFzB_HGg%2F-MiwX-GNFqntCt1dZ1t6%2Fimage.png?alt=media\&token=5458c63e-76ca-4c99-b07a-098c4d508048)

After completing the setup, you can start switching lightmaps directly in the editor, however, this will not work in play mode, since this requires a call to a special API. You can call this API according to your own rules, however, to simplify the example, a simple script was created that is attached to the "**Runtime Switching (0-2)**" objects in the "**Game Logic**" object.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MiwRcMZ_hrubFzB_HGg%2F-MiwawPbS8jktRsiiZfZ%2Fimage.png?alt=media\&token=61be0d43-8ab6-4de3-9802-118e755e0772)

This script calls the Switching API and contains two options - "**Lighting Scenario**" and "**Lightmap Index**". Using the Unity selection window, select the appropriate scenario for script. The name of the scenario created for a particular scene begins with the name of this scene, for example, for **Quick Start** scen&#x65;**,** this will be the scenario **Quick Start\_New Lightmap Scenario\_0**.

Assign a lighting scenario to all three objects.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MiwRcMZ_hrubFzB_HGg%2F-MiwgAL8eh0kgDYjIsDF%2Fimage.png?alt=media\&token=3a5d44c7-58a9-46ac-908f-1488b490f59d)

You can now test switching lighting maps in play mode. Disable the "**Runtime Blending**" object as it is not configured and go to paly mode.&#x20;

Move the Cube object along the **Z** axis. You will see the lightmaps switching.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MiwRcMZ_hrubFzB_HGg%2F-MiwgmM3mIq1bRd31WL2%2Fimage.png?alt=media\&token=eb266d64-25a0-4e0f-8e46-7026b24fd9f6)

### 4.2. Lightmap Blending

To check that everything is working correctly, switch to the **Switching/Blending** tab in the manager window. The plugin automatically created a default **Lightmap Scenario** for you and added all saved lightmaps to it.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MYlG9cdRoe6OA-ITXBl%2F-MYlGKDXLcJ5BfIBetSR%2Fimage.png?alt=media\&token=b2bc77d8-24ed-4ddb-95b9-4d305e031af2)

{% hint style="warning" %}
Note! Reflection Blending Range and Lightmap Blending Range are important, these ranges should not be zero. Read more about how it works [here](https://motiongamesstudio.gitbook.io/magic-lightmap-switcher/system-components/mls-manager-window#blending-configurator).
{% endhint %}

Move the **Global Blend** slider. You should see the lighting data blend smoothly in real time.

After completing the setup, you can start switching and blending lightmaps directly in the editor, however, this will not work in play mode, since this requires a call to a special API. You can call this API according to your own rules, however, to simplify the example, a simple script was created that is attached to the "**Runtime Blending**" object in the "**Game Logic**" object.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MiwRcMZ_hrubFzB_HGg%2F-MiwZIvplCt8FJahXDxj%2Fimage.png?alt=media\&token=53a440e0-73dd-4f2c-b050-6f4e42a6019a)

This script calls the Cyclic Blend API and contains two options - "**Lighting Scenario**" and "**Blending Length**". Using the Unity selection window, select the appropriate scenario for script. The name of the scenario created for a particular scene begins with the name of this scene, for example, for **Quick Start** scen&#x65;**,** this will be the scenario **Quick Start\_New Lightmap Scenario\_0**.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MW4wLo1cA3DrheVakRu%2F-MW4xKrY2oX-rcYkycYB%2Fimage.png?alt=media\&token=64007876-44b5-47f0-96d8-3e79120b600e)

Now you can start playing. Once launched, the script will automatically run.

![](https://484743511-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-ML4jBQpiY0hXPLy-BzC%2F-MW4wLo1cA3DrheVakRu%2F-MW4yLLb2Q3oxyWNKffx%2Fimage.png?alt=media\&token=2025874f-abd3-478e-a0eb-3c05eb4659e3)
