- Home /
Beast Lightmapping Black Seam Problem
Hi All,
I am getting black lines where objects intersect when baking lightmaps with Beast. Is there any way to avoid this besides combining the meshes? I thought "edge dilation" would do the trick and am using a BeastSettings.xml. To me it appears changing the edge dilation value does nothing at all - is this currently broken? (I'm on Unity 3.5.1 Pro). I also see no changes if I change the bgColor attribute in the same section. What are valid values for that?
The image is baked using no Ambient Occlusion btw. It's just two hi-poly objects without any textures etc, but they are properly UVed. The seams come from texture interpolation of the dark shadowy parts where objects are intersection. What I basically need would be the light colour to go on for a few pixels - exactly what I though edge dilation would do.
The problem gets worse if I reduce lightmap resolution and the lines get finer if I increase it, but an even higher resolution is not really an option.
Just curious. What happen if after the baking, you disable the renderer of the right objects? Could be that Beast is casting a shadow on the left object.
Yes, those objects cast shadows on each other. If I hide the right object, I get a black area where the objects are intersecting. The visible black seams are the borders of these shadows and due to the lightmap being an interpolated texture, these shadows "bleed" out onto the visible surface. What I'd like to have is a way to shrink those shadows. I can make the issue go away by disabling shadows for those two objects, but then I also loose the shadow on the ground + the correct shadows on the back side. And lightmapping without shadows seems kinda pointless.
It's probably too much to ask from light-baking, but ideally there would be some difference between surfaces that are in the shadow and surfaces which are on the inside of other meshes.
Answer by Kryptos · Apr 23, 2012 at 12:17 PM
Detecting whether a surface is inside or outside any other mesh is not a simple task. It is possible for convex meshes but much more difficult for arbitrary geometry (and often undecidable in decent computational time).
Your best option is to combine the two meshes into one.
Edit: for references, there have been some work on related issues. Not sure if it has already been integrated in any engine/library.
[[rosen08] Seamless Intersection Between Triangle Meshes][1]
Edit2: also found this page (it is for UDK, but can also apply to any engine using lightmapping techniques).
[1]: http://web.cs.swarthmore.edu/~adanner/cs97/s08/papers/rosen.pdf
Thanks for your answer. However - while this would solve the problem with the seam between the objects, I'd still get the (more annoying) seam at the ground. And I'd really like to be able to reuse meshes without having to combine them. Additionally I have LOD Groups on these meshes.. which makes combining somewhat impossible.
Something that almost does what I need is to enlarge the two objects a bit after baking the lightmap - but that wouldn't work for a large scene with lots of objects.
Thank you very much for the edits and that interesting research paper. So at least I know the problem is "valid".
I found out in the meantime I can write an editor script which encapsulates the lightmapping process and I'm pondering to write one that scales tagged objects down a little bit before baking, then triggers the bake and the scales them back to their original size afterwards. That should get rid of most of these seams in my case.
Reading through this again I have an additional thought. Deter$$anonymous$$ing whether any point is inside any other mesh in my opinion IS quite a trivial task. Just cast a ray to infinity and count the intersections with all surfaces. An odd number means you're inside some other mesh and the point is not part of a visible shadow. Using this maybe lightmapping could be made to write the bgColor to "inside-texels" and then the special lightmap mipmapping/texture interpolation would not produce the black seams.
I'm sorry for digging up such an old thread, but I have a pretty similar question (http://answers.unity3d.com/questions/584657/intersecting-objects-cause-black-lines-in-lightmap.html) and wanted to know if you found a solution? I know you can combine the meshes, but that's just not a solution for a whole level. Did it work out for you in the end?
Hi $$anonymous$$dlessblahs,
I did not find a solution and I'm afraid there isn't any. But I figured out what the problem really was. Beast colours all areas of meshes that are inside other meshes black. Which seams fine, but of course the ususally quite-low rez textures also get interpolated while being drawn. This leads to the black on the inside "bleeding" out and these black lines appear. As I anyway planned on using ambient occlusion, I stopped worrying about it after a while.
An ideal solution would be for beast to make lightmap areas inside other meshes transparent and then use some processing to extend the lightmaps into transparency. $$anonymous$$aybe if we had full control and would understand beast settings, it could be done.
It would also be possible to postprocess lightmaps. It is possible to deter$$anonymous$$e the world-coordinate and object for each pixel in a light map. Then you could to a raytrace to infinty to deter$$anonymous$$e whether it's inside something else (as described higher up) and if so, manually fix the black pixel with something better. Of course the filtering on the lightmaps would work against you, but this could maybe be disabled by using low quality for baking and then doing filtering yourself after fixing the black pixels.