Unity Lightmapping, Layers, & Multiple-Terrains

Our team (which is basically me on engineering) has been dancing and struggling with the Beast Lightmapper for a while now regarding this issue. We have a fairly complex Unity scene where we’re using the layer system to limit the parts of the level the lights are affecting. We also have multiple terrain instances in our scene.

Now, when we try to use the vanilla Beast lightmapper and just ask it to bake the scene, it doesn’t appear to respect the layer culling in the lights. Lights in our “Dark” layer cause shadows to appear on items in our “Light” layer when the Dark lights, when operating in realtime, don’t illuminate that geometry at all.

We got around this issue with a bit of code I wrote I’ve been playfully calling the BeastWrangler. This code is breaking the scene up into sections and running light backs on individual areas, sometimes even individual rooms to ensure that we don’t get shadow-bleeding between light layers. This all works well and good until we get to Unity’s terrain system.

While the system works well when there is a single terrain in one of our levels, multiple terrains seems to lead to some strange misbehavior where the terrains are being influenced by all the lights, no matter what I do with the BeastWrangler code.

So, the base question is this. What can I do to get Unity’s Beast Lightmapper to output the correct shadows in a more complicated scene? I’m attaching pictures of an example scene that demonstrates the struggles I am having.

  1. What the scene looks like with realtime lighting. This is what I’m expecting as a result from the shadow bake.

  2. The result I’m currently getting out of my Beast Wrangler script. As you can see, the meshes in the scene bake with their lighting correctly. The terrains, however, are not at all correct.

first I would make sure you have Generate Lightmap UV’s checked in the mesh import settings. That might fix it if those are planes and not Unity terrains. If they are Unity terrains I dunno, it should work–maybe also try lowering your directional light intensity and make sure the trees’ shaders are set to the proper (Nature?) shaders–it’s been a while and I haven’t used Tree Creator yet, but there is a “bark” and “foliage” shader under “Nature”, from what I remember.

edit: reading through what you are trying to do again, your situation does sound super-complicated for doing in Unity, unfortunately. In my experience, multiple terrains is no good. On top of that, you have multiple lighting schemes. I’d probably agree with balloonanimals in that you may want to try baking in Maya/3DS/etc. getting the textures from that, then importing into Unity–switch them with some script, etc…