Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Lightmap problem - black objects (unity 5)

Discussion in 'General Graphics' started by brainchild-pl, Mar 20, 2015.

  1. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    I tried to bake a lightmap in Unity5 but couldn't get it done right. I have no idea what is going on. I set "generate lightmaps" on imported .fbx objects. Every object is set to "static". I have got soft shadows on my Directional Light and there is 1 texture atlas for all objects.

    Here are my settings:


    http://i.imgur.com/iO10Yfd.jpg
     
    Last edited: Mar 20, 2015
  2. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
  3. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    I have the same issue on my scene. Weird black or white patches on some objects after lightmap bake.
     
  4. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    Yeah... I am really confused. I had no problems in Unity 4.x
     
  5. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    gi_weird_issue.png Here is how this issue look in my test scene, btw. Both in Realtime and Baked lighting.
    Sent bug report to Unity team.
     
  6. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    anyone? It is pretty annoying and confusing.
     
  7. Xalvor

    Xalvor

    Joined:
    Jul 5, 2014
    Posts:
    5
    Yes please, someone needs to clarify on this.. happened to me too. Objects went black, casting pitch black shadows. I was going crazy and I even rebuilt a whole scene. It fixed itself when I lightbaked again..I really do not understand the whole lightbaking thing, do I need to select all objects? Lights/terrain too?

    It never works, I tried it more than 20 times and the results are S*** (esp waiting 20 mins per bake), and when it actually creates the maps, there are no shadows being cast on the terrain :/
     
  8. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    Try to create very small test scene with only few objects then play with GI settings and params. I spent few days experimenting that way before found best recipe.

    BUT, problem with black weird patches still persist and very, very annoying!
    Also the same problem it this thread: http://forum.unity3d.com/threads/lightmap-artifacts-dark-spots-in-unity-5.307532/
     
  9. NomadKing

    NomadKing

    Joined:
    Feb 11, 2010
    Posts:
    1,461
    Post the case number of your bug report here. When a Dev looks at the thread it makes it easier to find the repro case :)
     
  10. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    Yes, I will, but I sent report few days ago and still do not receive confirmation email with case number. Do not know why, double checked my email - all correct.
     
    NomadKing likes this.
  11. RogerRen

    RogerRen

    Joined:
    Jan 5, 2015
    Posts:
    10
    maybe you need to selelct the final gather
     
  12. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    Final Gather change the result but not so much. Black/white patches is still there.
     
  13. RogerRen

    RogerRen

    Joined:
    Jan 5, 2015
    Posts:
    10
    how long to baking lightmap everytime.... I think it is some problem with the baking time , It's so long ... S*** !!
     
  14. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    So, can anyone help?
     
    Last edited: Mar 24, 2015
  15. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    Now tried to play with "Auto UV Max Distance" param. Set it to 1 for object with weird black patches and it looks good on my small test scene with realtime and bake lighting.
    Not sure with drawbacks of this solution.
    Hope Unity team will look into this issue.
     
  16. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    den3d: Did you get any info about your bug report?
     
  17. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    No, nothing.
     
  18. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
  19. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    do you have more than one light casting shadows?
     
  20. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    Nope, I have just 1 light. I even recreated the scene to make sure the old scene wasn't the problem. (bugs etc.) It hasn't helped at all, I have got still the same problem.
     
  21. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    It seems that your leaf geometry is single-sided and that causes the trunk to mostly see backfaces.

    By default if a point on your geometry (we call it a ray origin) sees more than 10% of backfaces it is marked as invalid. Invalid ray origins are not affecting the radiosity computation. If all the ray origins of a given texel are invalid then the lighting for that texel is cloned from the neighbours.
    This is done, so that e.g. intersecting geometry doesn't cause dark artifacts (texels within some geometry getting black don't bleed outside).

    Let's consider this simple case of a cube intersecting a plane.

    Backface tolerance at 0.9 (default) - ray origins that see 10% of backfaces are marked invalid:
    BackfaceTolerance90.png

    Backface tolerance at 0.0 - all the ray origins are valid no matter how big percentage of backfaces the ray origin sees:
    BackfaceTolerance00.png

    In the second image you can clearly see that the texels on the plane that are within the cube are dark and bleed outside of the cube. Also, texels on the cube that are partially below the plane bleed above it.

    So in your case I would recommend creating a new LightmapParameters asset specifically for trees and dialing down the Backface Tolerance until the issue goes away.
    Cloning valid texel data into invalid ones happens just for one step, that's why having a big patch of invalid texels gives you a black result.

    Docs:
    http://docs.unity3d.com/ScriptReference/LightmapParameters-backFaceTolerance.html
    http://docs.unity3d.com/Manual/LightmapParameters.html
     
    KpLeR, Hoorza, IgorAherne and 3 others like this.
  22. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    Also, in cases when you don't get the confirmation e-mail for your bug submission:
    • please check your spam folder
    • if it's not there, submit again after a day or two
    Thanks!
     
  23. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Good info, thanks!
     
  24. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Thanks for tips... setting "Pushoff"to 0.14 helped to get rid of black shadow dots spreading across environment
     
  25. Dixonycf

    Dixonycf

    Joined:
    Sep 7, 2017
    Posts:
    1
    Those black things are gone after I build the game into .apk or .exe. In my case, it seems to be temporary, it returns to normal after building the game.
     
  26. dom_cobb_22

    dom_cobb_22

    Joined:
    Feb 6, 2014
    Posts:
    24
    Hey people.
    Got some similar problem. I have a wall with a tiny window (which is extruded into the wall). With real-time light, everything seems right, but when I bake with area lights, that part of mesh appears absolutely black. At the beginning it was a separate mesh element, I thought that is the problem, but now I weld this element into a single mesh, and the problem still on the same place.
    Next, I tried to create new lightmap parameter with backface tolerance set to 0, but it did not solve this problem.
    Now I don't know what I can to try more. Can you tell what it can be in this exact case?

    Real-time light on the first image. The model present on the last. And the issue in the middle.
    0.png 1.png 2.png

    Unity 2018.3.13
     
    radiantboy likes this.
  27. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Did you solve this ? I'm having similar issues. Realtime looks fine backed just shows no light at all - so weird
     
  28. Shukerullah

    Shukerullah

    Joined:
    Mar 15, 2013
    Posts:
    97
    Solution?
     
  29. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    for me it was related to using bakery in the past, it set the lightmap scale to 0.0 or something, check that on the mesh renderer.