Lightmapping; Baking in runtime

Hello! :slight_smile:

I am making a voxel game, and so far, as I understand, lightmapping and baking can be done in the editor, by selecting the light sources, the terrains and then baking everything. However, I do not have anything in the Unity editor to bake, because terrain is generated at runtime.

Because google has not yielded anything in regards to baking at runtime, how can I bake my terrain after I have created it after running the game?

Basically, lets say it creates 4 chunks, and the game/map has a directional light, how can I script it so that lightmapping and baking starts after the terrain is generated?

Thank you! :slight_smile:


There seems to be this bug: alt text

It seems like the shadows arent properly displaying at these type of locations, I assume this is due to not having shadows baked, am i correct? Adjusting the Bias also didnt help

Edit: I adjusted the light bias to show the problem more clearly: alt text

Lightmapping on runtime, even if it was possible, is not a good idea. See, thebeast.exe (32 or 64 bit) runs exclusively after you send your mesh renderers into its queue, and it starts to process them, using around 95% of your CPU and 3-4 GB Ram at the very least, making game (even the editor) unplayable / unusable.

So, here, lightmapping on runtime is not the answer to your question. You can either create chunks and lightmap them, then instantiate them to build something bigger, or stick to dynamic lightning.