laurenth-personal / lightmap-switching-tool

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

openupm click this badge to go to the open upm page for this package

Lightmap switching tool

Tool intended for switching pre-baked lightmaps, light probes and realtime lighting on a static scene at runtime.

Depending on the platform or depending on the content, the switch might not be instant but take some seconds, this script just allows you avoid duplicating your scene if you just want to change the lighting.

This version is compatible with unity 2019.3 and above, check previous releases for unity 5.5 - 5.6 version.

If you want to use lightmaps of different resolutions in your different lighting scenarios you will probably need to disable static batching in the PlayerSettings (if you use the same lightmap resolution on all your lighting scenarios and the object packing in the lightmap atlas doesn't change accross lighting scenarios it's ok to keep static batching enabled).

The system relies on the LevelLightmapData component :

It references the different lighting scenes, builds the lighting, and stores the dependencies to the lightmaps.

If your lighting scene contains Realtime/Mixed lights or Reflection probes, the script will consider it's necessary to load the lighting scene at runtime to replicate the full lighting. The lighting scene will thus need to be part of the "Scenes in Build" list in the Build settings (File/Build Settings).

How it works

Scriptable object workflow

Tutorial

Supports

Static batching

If you want to use static batching, lightmap scale and offset cannot be applied at runtime. Make sure your lightmap resolutions are the same in all lighting scenarios, and on the LevelLightmapData component make sure to disable "Apply Lightmap Scale and Offset".

How to install (2020.2 and Newer)

Importing the sample :

FAQ

Contributors :