Search Unity

Lightmapping artifacts appearing when baking many objects.

Discussion in 'Editor & General Support' started by Futurerobot, Nov 7, 2012.

  1. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    So I'm experiencing artifacts when baking a scene with beast. It's almost as if dark creases are "radiating shadows" outwards, and sometimes it just seems random. See the circled areas, artifacts on the ground plane.

    $lightmap_artifacts.png


    However if I select just a few objects, and do a Bake Selected, then the artifacts disappear and it all looks fine. I get the same clean result by deleting other objects, and doing a bake scene. It's as if a certain amount of objects in the scene causes the issue. I should also mention that it doesn't seem to be any specific objects in the scene causing this bug, the same rocks and groundplanes are present in the artifact-free bake selected, as in the buggy bake of the whole scene.

    $lightmap_clean.png


    The scene is fairly simple, Unlit(Supports lightmap) material, no texture, all meshes (for testing purposes) have been set to generate their own lightmap UVs. Lighting is just skylight and directional light.
     
    Last edited: Nov 7, 2012
  2. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Still getting this problem, and sometimes a lot more noticeable that this. Some of the artifacts are different than these, and appear as shadows that are appearing from nothing and then "cut off" as if there's an UV tile gone wrong. However when I look at the mesh, the cutoff line goes straight across a completely solid polygon, not following any meshlines.

    Anyone have an idea what causes this, or experienced it themselves and got rid of it?
     
  3. shinichi88

    shinichi88

    Joined:
    May 4, 2011
    Posts:
    80
    Would you mind posting some screenshot of the artifacts??
    If possible post your Beast Lightmap settings as well..
     
  4. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    There's supposed to be two screenshots in the top post. I wasn't able to see them myself at first, but they appeared in the end. Are they displaying for you?

    The beast settings aren't anything special, default settings. Quality set to high, bounce to 4, and skylight intensity to 1
     
  5. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Another screenshot, this is without directional light and ambient occlusion. Only skylight. Quality High, bounces 4, resolution 10, rest of the settings are default.
    $lightmap_artifacts_2.jpg
     
  6. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Here's another two shots with a very obvious artifact. Selected them to show the wireframe as well First what it looks like with the whole scene baked (buggy)
    $lightmap_artifact_3_bad.jpg


    And here's what it looks like with just that segment of ground and rocks baked with bake selected. (no bugs!)
    $lightmap_aritifact_3_good.jpg
     
  7. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Could someone confirm if they're actually seeing any images here? For me they appear, but not always. I'm using the Manage Attachments menu and the Insert function.
     
  8. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Yeah, I can see the images. When I get these artifacts it usually means that some mesh's secondary UVs are unwrapped improperly. Even a single mesh with improper UVs can cause artifacts in unexpected places. You mention that you are unwrappping the meshes in Unity though so it's probably something else.

    How is your AO set up? Are you using a big number for the Max Distance setting?
     
  9. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Ambient occlusion is disabled for these tests in an attempt to isolate what's causing it. It seems it's probably something with the skylight.

    My settings
    $lightmapsettings.png
     
  10. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    What happens if you use a Sky Light Intensity between 0 and 1? Also set Padding to 1 or 2.
     
  11. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    The darker picture above (the one right before the two bright ones) is with a skylight intensity of 1 you can see the same artifact there. I just boosted the light a bit to see the artifact better when I tested on. Padding I believe is on in the first picture showing the artifacts, also something I turned off just to make sure it wasn't a padding-gone-wrong.
     
    Last edited: Nov 9, 2012
  12. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Baked scene with sky light intensity of 0.7, and padding of 2
    $lightmap_artifact_4.png


    And the same area baked with bake selected.
    $lightmap_artifact_5.png


    Note: These are not the same rocks as earlier in the post, but from a different place in the scene. I was duplicating the assets a couple of times to see if it got worse with even more objects. These changes kind of randomize the artifacts and make them appear elsewhere.
     
    Last edited: Nov 9, 2012
  13. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    On the previous pictures, the ground consisted of a lot of square tiles snapped together, in the way we build our levels with modules.
    I tried exporting just a huge two-triangle plane, and using that as a ground. Interestingly, this increased the amount of artifacts by a huge amount.

    $artifact_6.png
     
  14. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Try clearing the lightmaps before baking. Also worth trying this in a fresh scene. If that doesn't work send me the scene in a PM and I'll have a look.
     
  15. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Clearing Lightmaps/ New scene didn't work. Sending it over to you, thanks!

    Edit: Actually, can't find an attachment button in the PM window. How do I send you an attachment?
     
    Last edited: Nov 9, 2012
  16. Loards

    Loards

    Joined:
    May 2, 2013
    Posts:
    112
    I have exactly this same problem, did you found what it happening?? its really dumb to make a whole escene bake, an later have to bake the asset with errors one by one.
     
  17. brAvatar

    brAvatar

    Joined:
    Mar 17, 2013
    Posts:
    8
    I had exactly the same problem, and nothing helped.
    The problem was due to multiple mesh objects in one fbx/max file.
    After I saved each mesh object in it's own file, problem solved. It is probably due to lightmaping UV calculations when many objects in one fbx.
    Doing the same with dynamic objects have no problem, only in static once.
     
  18. brAvatar

    brAvatar

    Joined:
    Mar 17, 2013
    Posts:
    8
    Actualy it didn't helped. But improved it.
    What also helped is to change "Hard Angle" value from 88 to 43 in fbx import settings.
     
    Last edited: Feb 22, 2014
  19. brAvatar

    brAvatar

    Joined:
    Mar 17, 2013
    Posts:
    8
    After many other settings and some tuning with Lightmapping-Extended, I think/hope I found the solution:
    When I set texture size from 1K to 2K it solve the problem (for now at least).
    But you need to do it manualy in the code with the next too lines:
    LightmapEditorSettings.maxAtlasHeight = 2048;
    LightmapEditorSettings.maxAtlasWidth = 2048;
    Then after baking, go to texture files and change import image size to 2K.
     
  20. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    $8oVN6.jpg

    i have lightmap look cutted when to mesh is close

    i already get the trouble one time i don't know how fix it please heal