Baking light on a procedurally generated tilemap

Hi,

For a mobile targeted game, I plan to create a tilemap which I estimate will be up to 50k triangles.
In order to optimize it, I decided to use very few textures.To further optimize it, I also want to bake the lightmap. However, I’m not sure if it is possible to do on a procedurally generated tilemap.

Because as far as I know, usually to bake the scene, they import all models and lights, mark them as static and then bake them. The problem is, I won’t have my map in the editor, it will be generated when the Awake() function is called. So I started to wonder if this is possible at all…

Many thanks in advance for your support.

You can’t bake static lightmaps in the player, so you have to consider other options. One solution would be to bake smaller chunks of the level separately and piece them together using LoadLevelAdditive. Another would be to use
Unity - Scripting API: Lightmapping.BakeMultipleScenes if you need shadows and GI between some level segments.

You can’t bake lightmaps at runtime. You could use realtime lighting and an ambient occlusion image effect. Both of those options are going to be expensive on mobile.

Just beware that you can’t use lightprobes if using this approach.

Lightprobes can’t be loaded additively, and even if they could, they can’t be moved/rotated at runtime (when you position your tiles)

Light probes can be loaded additively. I’m doing that in this demo. I first unload the loaded scene with baked light probes then additively load a new scene with new baked light probes and it works fine. I know that doesn’t help with the original issue of how to bake proceduallly generated content but I just wanted to make the point.

Use the ‘E’ key to go through doors. The red and green room both have baked navmeshes and baked light probe groups.

https://dl.dropboxusercontent.com/u/496463/WebGL/index.html

You might consider Mesh Materializer to bake AO either at design or runtime.

https://www.assetstore.unity3d.com/en/#!/content/28583

2347181--158875--upload_2015-10-20_13-6-7.jpg

1 Like