I’m encountering a strange problem with Enlighten in Unity 5 when baking lightmaps for my terrain mesh, which consists of combined single tile meshes. The following image shows a very basic scene with only one tree and four plane terrain meshes. It uses a directional light with baked lighting, precomputed realtime GI is turned off and the directional mode is “non-directional”. All other settings are mostly default and I was not able to fix the issue with the various tweaks I tried:
As you can see, the shadow is messed up and each tile seems to have the same lightmapping UVs. The messed up section around the tree is a single mesh consisting of 6x6 quads. The quads were combined using a script which converts a 2D tilemap into a 3D mesh by merging the meshes found in a set of prefabs (one 2D tile is mapped to one prefab) into a single mesh. However, I limited the mesh size to 6x6 tiles, that’s why the leftover tiles in the example are put into different meshes.
Maybe I just didn’t understand what Enlighten actually does when generating and my complete plan is just bullsh*t. Is it a problem for lightmapping when triangles share the same UVs in a single mesh? It actually looks like if the bake result for the last tile in the process was taken and put onto all other tiles.
Did I miss something important, e.g. when generating the meshes using CombineInstances? I also enabled “Generate lightmap UVs” in the import settings. This issue is driving me crazy because I tried so many options but nothing made a difference.
Thanks for your reply. No, everything looks fine with precomputed GI, but there are no lightmaps generated either. What do you mean with UV problem? Is it because of the mesh I generated or is it a problem with Unity/Enlighten?
Well, if everything looks fine with precomputed GI means is a UV problem from your side, because Enlighten generates it’s own UV’s if you use precomputed GI. Did you inspect meshes UV in both cases?
I’ve tried to use prefab instances now instead of combined meshes and the problem was no longer there. So it seems something weird is happening with the UV2 set when combining meshes. This is the code I implemented, nothing special I think:
CombineMeshes do nothing more that says. The UV generation is the problem, how you did it? Since is a simple quad patch is easy to unwarp, just be sure you let 0,1% at margins to don’t get any other artifacts.
UV1 is laid out in an atlas with many other tiles, it doesn’t map to texture corners with only 0 and 1 coordinates. UV2 was generated by the importer. I’m on my way now, but I will check the coordinates later. I just find it strange that prefab instances work as they should while combined meshes do not, even if they do not more than you already said.
Both sets are the same for the original and the combined mesh. There is actually one edge of the plane that hits the border of the texture. Is this the problem? And why does it occur with combined meshes and not with single prefabs?