Monday, March 7, 2016

F**** Lightmappings

Ahoy!

Lets deal with those horrible lightmappings.

I have this Spirit palmtree, with this Uv Set:



Looks nice. The leaves have their UVs overlapping.
So lets go to Unity to do a test. Just put a few on the scene, a plane (checked them as Static) and a direct light. I used the default parameters with the Directional Lightmap but changing the resolution to 12 in order to speed up the process a bit.



I´m having always bad results when I do the lightmap. The projected shadow on the texture is incorrect. I saw this on forums as"Bleeding Shadows".

We can fix this easy. Lets go to Maya (or whatever soft, it will work too).
Problem is, Unity needs another set of Uvs per Static mesh in order to calculate the Lightmapping. This Uv set (the lightmapping one), needs to have non-overlapping faces, and a bit of spacing between them so the shadows doesnt project on to each other)





Now we should have two identical Uv Sets:



Select your mesh and go to Polygons, Layout Uvs Options (while you have selected the desired Uv Set). This are my settings:



As a result I got this:



We still use the first Uv Set for the Texture, and the second Uv Set for the Lightmapping.

Now our mesh is ready to be Lightmapped ;)




Have fun!