- Home /
How to load enlighten lightmaps correctly at runtime?
We are attempting to make a game that will consist of an "endless world" of sections that are loaded at runtime.
Each section will be contained in a scene with it's own lightmaps. Currently we are using the LoadLevelAdditiveAsync method to test loading the scenes into an empty 'loading' scene. First we load the scenes, then we load the baked lightmaps from each scene into the LightmapData array, then we assign each renderer in the scene to look at it's corresponding lightmapIndex, and we set the lightmapScaleOffset back to it's original value.
Here is a video of the one time that I actually managed to get it working... but I haven't been able to get it to work since.
Here is a video using another scene with my own meshes. (to test that UV mapping of unity primitives wasn't the problem). The first part shows the scenes with their lightmaps perfectly applied - no lights in the scene. The next part shows the loading scene with the scenes loaded side by side and lightmaps applied. As you can see, the lightmaps come in at the wrong scale and placement.
There are a couple of things I have noticed that I'd like someone to please explain to me or give me some insight on:
No matter what value we set the lightmapScaleOffset value to, it doesn't change how the lightmap is loaded onto the renderers. So then my question is, what does the lightmapScaleOffset actually do?
When I place a Lightmap Snapshot from one of the lightmapped scenes into the Lightmaps section of the 'loading" scene, the scene that the snapshot came from loads correctly.
I opened the LightmapSnapshot.asset file as text, and I noticed that there are some promising looking attributes in Enlighten System Information: rendererIndex, rendererSize, atlasIndex, atlasOffsetX, atlasOffsetY. Would it be at all possible to use the attributes to set up our loaded lightmaps correctly?
Any insight or solutions to this problem would be much appreciated ;)
A small update. As makes sense, if your GameObject is set to static, at runtime it becomes a combined mesh object in the inpector, but this also seems to affect the lightmap UVs. Ins$$anonymous$$d of setting the gameobject as static, if you rather go into the lighting window and set the renderers as 'Lightmap Static' and "Preserve UVs', then the 'lightmapScaleOffset' value in the renderer does have an effect, but still not right.
Answer by JanusMirith · Mar 12, 2015 at 12:45 AM
Turns out it is a bug:
Unity bug tracker http://issuetracker.unity3d.com/issues/gi-is-broken-if-loadleveladditive-is-used
Forum post http://forum.unity3d.com/threads/gi-and-additive-scene-loading.286807/
I think the only way to fix this is to Vote for the bug, I am surprised that there is so few votes on it so far.
If anyone manages to get a fix please share, at the moment my only options are to go through all of my scenes and strip every light or push the minimum requirements up to that of a supercomputer.
Haha! Yeah, unfortunately those seem to be the only options for now...
Thanks for the info. Those 2 links you posted are linked to the same thread, are they supposed to be the same?
As much as it might be a bug, it's also about not having access to all the properties. If we could access the lightmap snapshot, we might be able to get around the problem.
Answer by DarekLosu · May 20, 2015 at 11:14 AM
I've also had similar issue, but found a way around it. Try assigning lightmapScaeOffset and realtimeLightmapScaleOffset.