- Home /
The question is answered, right answer was accepted
How can I change directional lightmaps at runtime?
Hi there.
I am using lightmaps in a scene baked with directional lightmaps mode, and it generates the color and scale textures. Is there a way of changing it at runtime?
The idea is to load low resolution maps when starting the app while loading the full lightmaps from an asset bundle via WWW object. (just to minimize the size of the unity player, as it is a web project) I have searched and all I have found is the lightmapNear and lightmapFar answer (which btw was really helpful).
I have searched the docs and I am not sure what to use instead of lightmapFar and lightmapNear to set the color and scale textures. Any ideas?
Thanks in advance.
Answer by MakeCodeNow · Feb 18, 2014 at 05:51 PM
Unity stores the current set of lightmaps in LightmapSettings.Lightmaps. All lightmapped objects have an index into this array and...that's it. If you want to change the active set of lightmaps, simply change the contents of the Lightmaps array. You can modify it however you like in the editor or in game. Just know that changes you make in the editor will be overwritten when the user next bakes lightmaps.
PS - I believe that LightmapNear and LightmapFar are used with Directional Lightmaps, too. The variables should really be called LightmapSlotA and LightmapSlotB.
The names is the cofusing part. I'll give a try to setting the color texture at the lightmapFar and the scale texture at the lightmapNear (and viceversa if it doesn't work). Thanks!
Definitely confusing. Please mark this question as answered if you got the information you needed.
The PS part is the key. Names are a mess but work as slots for the textures, sort of lightmapFar equals slotA and lightmapNear equals slotB.