Skip to content

This API allows you to create multiple lightmaps "atmospheres" for the same scene and switch between them in runtime dynamically, or you can make multiple environments as dynamic gameobjects where you can enable, disable or instantiate it at runtime and switch between the previously baked lightmaps "atmospheres" for these environments when needed.

License

MahmoudKanbar/Unity-Dynamic-Lightmaps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Dynamic Lightmaps

This API allows you to create multiple lightmaps "atmospheres" for the same scene and switch between them in runtime dynamically, or you can make multiple environments as dynamic gameobjects where you can enable, disable or instantiate it at runtime and switch between the previously baked lightmaps "atmospheres" for these environments when needed.

Unity_qOGRQ5Pu8y.mp4

How to use this API

1. create the environment you want inside the scene as static gameobjects.

image

2. bake the lightmap for this environment.

image

3. open the "Window -> Dynamic Lightmaps" in the editor.

image

4. select the static objects that represent the environment you want in the editor, And press "Add Map Data Attacher to Selections" don't worry the editor script will automatically applay the changes to the prefabs, Then enter the LightState name, Then press "Save Current Light State".

image

5. you will find all the saved light states in the folder "Assets\Light States".

image

6. now you can remove the static objects or the static label from these objects and append the light states for them in runtime using any script you want "CHECK THE MANAGER SCRIPT FOR REFERENCE.

image

7. if you open the manager gameobject you will find the Manager component which take care of LightStates and the environments we made previously.

image

8. if you wish you could bake the lightmap for the scene when it's empty to make a clean switch to the light states when the game starts.

image

Important Notes

This API support Light Probes inside Unity, But DO NOT CHANGE THE LIGHT PROBES POSITIONS AFTER THE BAKING IS FINISHED because Unity doesn't support changing light probes positions after baking is done and you can only change the probes positions using the editor it's write protected, also changing light probes positions or loading and combining them in load scene additive mode require Unity to perform a heavy operation called Tetrahedralize

So you have to keep the light probes fixed in the scene and place them with respect to all the environment/atmospheres you want to use.

About

This API allows you to create multiple lightmaps "atmospheres" for the same scene and switch between them in runtime dynamically, or you can make multiple environments as dynamic gameobjects where you can enable, disable or instantiate it at runtime and switch between the previously baked lightmaps "atmospheres" for these environments when needed.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published