Crash at end of lightmap bake

Hey guys,
I’ve been trying to bake lightmaps in Battle Of Endor for months now and so far it has been an exercise in frustration. Baking the entire scene would take days and ultimately end in a crash and a collossal waste of time. Maybe this is not surprising considering the size of the scene and the objects, though I was expecting a long build, not a guaranteed crash, right at the end of the build (just to maximize the time wasted).

I had no luck baking selected as it would always destroy previous bakes, but now all of a sudden it seems to be working without losing previous builds. So I started the tedious process of building each ship individually. I noticed it would crash on every second build unless I restarted Unity each time. This slowed things down even more of course but at least I was making progress.

But now for some reason it crashes at the end of every build even if I restart Unity each time, and even while baking lightmaps for duplicates of game objects that I have already successfully built.

I have used 109 lightmap slots in the Atlas. The progress bar completes and then Unity hangs for a minute just before it crashes. The log shows “Lightmapping complete” then "Crash!!! " (or something to that effect;I will double check when I get back to my pc) . I have 16gb of ram and it only uses about half of it or less so I’m not out memory.

Anyone else experience this? Any suggestions for fixes or workarounds?

Thanks!

I will outline my current workaround, which sucks so bad that hopefully someone will take pity on me and propose a better solution…

I noticed that the crash seems related to the number of lightmap pairs in the atlas; too high and it crashes. I had tried hiding everything but the objects I wanted to bake and got very excited when it baked without crashing… until I realized it destroyed all of the other lightmaps (fortunately I had gotten into the habit of backing up the lightmaps folder).

Using this info I duplicated my project, then started hiding everything but the objects I wanted to bake. I then renamed all of the exr files by hand, renumbering them all to append them to the end of the list of lightmaps I had already generated. I then copied these renamed files over to the original project’s lightmap folder.

I opened my original project and added the extra slots in the atlas, then dragged all of the new exr files into their corresponding slots (I made sure all of the renumbered files were still in the same order).

Then I selected each mesh, and in the Object tab of the Lightmapping window I manually reassigned the Lightmap index. This was pretty simple when doing a small batch, but by the end I was baking larger numbers of objects and had to note down which object corresponded to which lightmap.

Only after a full day doing this crap do I notice that in applying lightmaps I lose my bump and specular (unless I switch to deferred rendering). Well, !%@$.

Please, someone tell me I’m an idiot and that there is a simpler way to do this. I’ve done it manually this time (and developed carpal tunnel syndrome in the process), but at some point after enough significant changes to the scene I will have to rebake everything, probably with many more objects, and I don’t want to do this again.

I have crashes too on the end of Light baking.
Looks like unity is running out of memory on importing 4K Light maps.
Beast is 64bit but unity editor is not (not untill unity 5)

I’ve managed to have more success baking lightmaps recently.

First I made sure to clear lightmaps before starting a new bake (not entirely sure that helps but I haven’t had any crashes since I started doing that). Obviously that defeats the purpose of baking by selection, but I’ve actually been able to render the entire scene in a reasonable amount of time (can render it overnight or while I’m at work) and have gotten up to an array size of over 200 without crashing.

I also switched to Directional Lightmaps in the Bake tab, which gives me much more accurate shadows (I only have a single static directional light that casts shadows in the scene). Directional Lightmaps also supports my bump and specular maps, which Dual Lightmaps doesn’t in forward rendering mode.

My only remaining concern is what’ll happen when I inevitably hit the array limit of 254.