I’m having some trouble with lightmaps. I think I have done the UVs in Max for channel 2, but it seems that Beast uses a different set anyway? I have of course unchecked the generate UVs box.
Here’s an example - a simple piece of wall, consisting of 2 objects. In Max, I made the UVs to match in size, yet when I bake the lightmap in Unity, the corner piece gets far less resolution! I wouldn’t even care, but this leads to such a difference in the final look, that it gives away the seam.
Here’s another screenie with Unity’s checker map as diffuse texture - you can also see the underlaying lightmap resolution checker.
How come they differ? I have even tried swapping UVs in the import settings, but it looks the same - which is no wonder, since I copied the UVs from channel 1 to channel 2 in Max - yet Beast shows something else
After trying just about everything I could think of, I scaled the corner’s UVs heavily to see if it has any affect on Beast’s resolution at all - this was a little surprising. It looks as if they would almost match now, allthough from the UVs it’s clear that they don’t. Very strange :shock:
Going back to Beast generated UVs, I tried to increase it heavily, but I still get the dark seam between the two meshes.
When I took a look at the generated maps, I see “padding” within one mesh, but not between the two - how is this supposed to work?
Pack Margin in MeshImporter is margin for uv islands inside one mesh - so yes, it works correctly in your case.
As about margin between 2 meshes - i poked our beast guy, so can you please bug report it with repro case. Mark it as the case for Robert or Alexey
First of all - you have 2 submeshes in there - they are handled by beast separately, so there is why there is seam in there when you turn on lightmap resolution. Rest assured that this should be ok. I wasn’t able to repro different resolution on parts (you first screenshot), maybe you change smth like atlas scale or whatever. Also i was able to reproduce light leaking only with very small resolution - try to up it a little bit and/or increase pack margin. Hope this helps
I should have been more clear. The resolution miss match only happened with custom made uvs - with beast-generated maps the resolution was fine all along, but the problem was the dark lines in the edges of the mesh. That’s why I tried making the custom uvs in the first place.
I will try to up the resolution now, can you give me any concrete numbers what you used to get rid of those leaks? I don’t see how the packing would help since - as you said - it just affects the shells withing one mesh. I have already tried pushing it to the maximum of 64 with absolutely no effect. Same goes for edge dialation, but resolution I haven’t touched.
I was able to get rid of the dark line with resolution of 200 (originally it was 50 texels)
This applies to the near map only, I guess, because if I zoom away from the objects, I can see the seam again. Anyway, this sort of works, but it would be awesome to have some other means to minimize the dark lines, because the maps get huge quickly if such resolutions are used - this is just a minimal example of 2 objects.
hm, seems like i was too fast - the behaviour is indeed erratic - changing resolution sometimes removes edge, sometimes move it somewhere.
With your max uvs resolution=30 was enough to have a rather good-looking lightmap. As for uvs generated by unity - i’ll take a look - is it our bug or beast
So about the first issue with mismatching uv scale: I opened the project that you sent with the bug report, looked at the lightmap resolution and it looks just fine if Generate Lightmap UVs is on (which is what was set in the project) and looks mostly ok (only the bottom of the wall has different resolution) when it’s off, but this is what you have put in your second UVs, so you should just double check that in max.
Beast doesn’t take part in the visualization of the resolution in unity - it’s actually dead simple and directly gets the 2nd uvs that are produced by the Mesh Importer (which are either the 2nd UVs as created in Max or UVs generated by the unwrapper).
Now one more thing that could’ve be wrong in your initial case, is that Scale in Lightmap values might be different on those two meshes. Since the left and right part of the wall are different meshes, maybe you accidentally changed Scale in Lightmap on of them.
About the second issue with insufficient padding between the meshes: as Alexey said, in mesh import settings you can only change padding between UV charts within the mesh. Changing of the padding between the meshes is not exposed yet in Unity and you can’t even change it via the Beast xml config file, because it’s exposed via the Beast API only.
We plan to add the padding setting and a bunch of other not-so-often-used settings to an advanced settings tab in the lightmapping window, but we haven’t done that yet. Hope fully it’ll happen soon.
When you notice that the lightmap texel bleeding re-appears when you zoom out - this is most likely due to sampling of a lower level mip-map, which has bigger texels, so they again start spanning over the adjacent mesh. It might be tempting to avoid that by turning off mip-mapping on the lightmap, but you shouldn’t do that, as it will negatively impact performance and you might also get other visual artifacts.
All in all sorry for the trouble you have with the bake, we’ll expose that setting soon.
The first issue can be disregarded altogether. I should have been more careful with the wordings and choosing the title of this post.
The miss-match of the scale originated from Max and was obviously a “user-error”
As for the important “second issue”, great to know you are exposing that feature!
I am just starting my project and doing feasibility study, so for now, I’m happy with the info that I can get rid of the leak-artifacts once you expose it. Of course the example images I posted were also very unforgiving - in the real project textures and normal maps will make the artifacts much less obvious, even if I can’t get rid of the light leaks completely.
Nevertheless, looking forward to see the feature exposed!