Search Unity

Black Spots Generated After Baking Lights

Discussion in 'General Graphics' started by EzraLee2015, Apr 6, 2015.

  1. EzraLee2015

    EzraLee2015

    Joined:
    Feb 20, 2015
    Posts:
    6
    Hello all,

    All of the Meshes and Scene in the photo have the following enabled:
    • Generate Lightmap UV's
    • Materials Assigned
    • All lights set to Baked
    • Compression Turned Off
    • Atlas Size is at 4096 BlotchyShadows.PNG
    I've searched the Forums seeking for answers on why "Black Spots" are appearing on my Meshes after baking the lights, the above is what I've found as solutions. I've also created a new scene and re-imported the models and cleared the GI cache. I still recreated the problem in random areas. The image is just an example of something that seems to occur in one location or many, inside and outside of the model.

    Any direction someone can give me to solve this problem with my scene?
     
  2. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    i get this issue often! if not always...

    the only thing to solve this.. Disable auto baking..
    clear baked lightmaps, save, re-open unity5 , then bake again and pray it goes away...
    sometimes it requires 3 tries to actually bake correctly..
     
  3. EzraLee2015

    EzraLee2015

    Joined:
    Feb 20, 2015
    Posts:
    6
    Thanks mangax for your reply!

    Just curious, are you using Unity for Arch. Visualization also? I just wonder if this seems to occur with bringing in models from Revit to 3dsMax. I've created another scene that was pretty complicated and I only had this problem once.

    I appreciate your suggestion. I'm going to test that.

    Also after I posted this Thread, I switched all my lights to real-time, just to see if it replicated the results I got. I didn't get any black spots. Than I switched back to "bake," and it worked fine!! Now I wonder if there was some kind of overlap with the baking process. I cleared the cache previously and nothing happened. Obviously from your approach and my own something happen when we just "restarted" the baking process. Do you think this is a bug we should submit?
     
  4. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Are you using Non-Directional, Directional or Directional-Specular? The latter being the hardest to get clean lightmaps with. I bring models in from Revit also and I'm using only realtime GI. The biggest problem i've had is overlapping faces in the geometry. In Unity 4 I could get good results, but Unity 5 is taking me a lot longer to prepare the Revit models. What is your workflow going from Revit to Unity?
     
  5. EzraLee2015

    EzraLee2015

    Joined:
    Feb 20, 2015
    Posts:
    6
    Directional.

    The only reason why I'm striving not to have any realtime lights is because we're producing web-players and making our Arch. Visuals Oculus ready.

    The workflow I came up with took some major time to prepare and troubleshoot due to experimentation. Also my inexperience with Unity initially and understanding how to build a truly optimized scene took time. The workflow is all done through a linked model, it would be so much easier if the model wasn't linked but I have to do this since we are making design decisions and changes within our firm constantly.

    1. Prepare 3D "Views" in Revit by splitting the model into logical pieces. IE Walls, Windows, Doors, Etc. into their relative locations and connections. With multiple views created I can bring these views into 3dsMax by linking the Revit Model and link the views I need and combine the elements by material. This is done so all "gypsum walls" will be brought in as one mesh in it's distinguished location (rooms) in the house or commercial building. I've reduced my draw calls dramatically by doing this. BTW when I say "split" I mean in these Views I hide elements I don't want to be imported with that view.

    2. I optimize any geometry that's too complicated. Typically railings or exposed steel of any kind or any other geometry that's custom.

    3. Typically Export the scene in 3dsMax as one FBX unless there are certain pieces that should come individually.

    Granted I know that my workflow in some areas needs some work. The biggest success thou was optimized scenes to walk through.
     
  6. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Yea, it had taken me a while too. I had it pretty much worked out in Unity4, had to start over with Unity 5. I have a similar workflow except i'm a consultant, and the models typically need a lot of work. Yea, bringing them in per material enables you to erase a lot of garbage.

    Couple of things you might want to try....

    - I split my models up with section boxes. You can't lock them to anything, like a reference plane or grid (it would be great if you could). But I found if you zoom in really close and adjust the bounding boxes, the precision takes over in max and they can create a perfect seam. Sometimes it takes more than one box exported and combined in Max to create a space. I only hide in view if I absolutely need to. This also enables me to re-link and bind an updated model preserving my export views.

    - Do you know the awful mesh created by railings and ductwork? I create a view of just that element and export it as an SAT. It comes into Max very clean. You'll need to rename the layer.

    - If I create a material of 1/32" thick, it comes into Max as a single plane. No wasted geometry.

    Also, i'm using real-time GI, but not real-time lights, except a sun. I lit my entire first project with emissive materials. Which is basically performance overhead free. And I can turn lights on and off and light the building with only the sun. Or light the building up at night, all in one scene without baked lightmaps. It's friggin awesome. I'll share a webplayer after my next build.
     
    theANMATOR2b likes this.
  7. EzraLee2015

    EzraLee2015

    Joined:
    Feb 20, 2015
    Posts:
    6
    This is great info! Thanks so much for sharing some insight! :D

    I've searched all over forums trying to understand a reasonable workflow due to changes to models over a course of time. I really appreciate this information due to the fact I've hit a wall and just had to play and play to figure out solutions.

    My email is james@ezralee.com - lets be in touch! You have some great insight and have even helped me to understand a better process to go about things.

    In regards to locking section boxes, I have an extension I've tried and it's quite nice but needs some prep to really make it work - DPR Model Slicer.

    I'm really curious as to how your working with your lights. Are you saying it's strictly emissive materials (attached to lights sources) and the sun to light up the building using no lights (point, spot, area) o_O? I haven't played with emissive material enough, i'd love to see the web-player due to the fact my first thought would be the emissive material just would be to intense to light up a room. Again love to see it and the quality, it does sound friggin awesome.
     
  8. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    My workflow when I was at a large EA firm was to start with a detached copy and make whatever modifications I needed and create my 3D views. Then I would bring in their changes periodically, by linking and binding copy/monitor only what changed. Dont get me wrong, it's still an enormous amount of work. We had all disciplines in house and I developed workflows for combining them to work in Unity reasonably well.

    Correct, I set up my light families in Revit in such a way and apply emissive materials to them in Unity. The attached images were takes at run-time with a directional light and emissive materials. The last one would have been far more dramatic if it were a reflective floor like tile instead of carpet. It's a 120,000 sf manufacturing facility and i'm getting about 120 fps with bloom, tonemapping and AA on the camera.

    example_00.png example_01.png example_02.png example_03.png example_04.png
     
  9. EzraLee2015

    EzraLee2015

    Joined:
    Feb 20, 2015
    Posts:
    6
    These are great examples topofsteel.

    Just to post one more picture of observation from the first picture, notice my mesh lines seem to follow the pixel pattern?

    Now is this just because of the mesh quality?
    MeshOutline.PNG
     
  10. Crevecoeur

    Crevecoeur

    Joined:
    May 15, 2014
    Posts:
    7
    Hi guys,
    I am in the same situation EzraLee2015. I am trying to optimize the lighting in my scene to have better performances.
    I just have one directionnal light used with my skybox. When I set my light on "Realtime" I don't have any problems but with "Baked" or "Mixed" I have dots appearing.

    I don't think it's linked with the mesh quality, on the picture below I have good quality mesh on the tank (on the left) and there are dots on it. You can also look at the ramp, it's just a cube with the same material as the ground.
    Moreover, I set shadows on "No Shadows" because I thought that was link but apparently it's not.

    So I don't know what I'm supposed to do, I will try the manual baking and pray that it works. ^^

    Sans titre.png
     
  11. EzraLee2015

    EzraLee2015

    Joined:
    Feb 20, 2015
    Posts:
    6
    Crevecoer,

    Thanks for posting. Same issues over here with the "realtime" vs. "baked."

    Today I saved my 3dsMax scene into a new scene to see once again if I create a new scene and watch what happens to to replicate the issue. This is what I did:
    1. Took existing scene, and all links from that scene to Revit, I binded them.
    2. Export Selected to FBX
    3. Imported into a new scene with Unity
    4. Cleared GI cache
    5. Set everything to "baked" and added lights liberally within my scene and all my original materials from my previous model. (Baking was Continuous)
    6. I only set things to static initially that were my problem areas, eventually I set everything to static.
    Now my whole scene has not been replicated, I have had no issues yet. I did place all my "props" back in and when some of them were set to static, I was able to reproduce random black spots again, in different locations. Am I reaching some kind of "mesh" threshold? Are these particular mesh's bad so they are casting a weird black spot pattern? I'm going to try again tomorrow and see what I come up with.

    If anything, I have no problems yet until I imported my props for my scene.
     
    Crevecoeur likes this.
  12. Crevecoeur

    Crevecoeur

    Joined:
    May 15, 2014
    Posts:
    7
    Hi EzraLee,
    Thanks for your answer, I will try this later. I am currently on another project.
    I will give you my feedback here if it works or not.
     
  13. _M_S_D_

    _M_S_D_

    Joined:
    Nov 12, 2013
    Posts:
    511
    Hi!
    Anyone find a solution for why this happens? Since I moved over to Unity 5 I have been having nothing but issues with lighting. One scene doesn't bake (stalls completely), in another certain geometry is left unlit or max lit.
    So I have been starting work on other things until these issues get sorted and today encountered the black patchiness instead.
    Tried removing the baked light data and redoing the baking from scratch, but keep getting the black spots. Then figured it could be an issue with some of the Probuilder geometry I have been using as placeholders until I get to modelling it properly, but then found proper meshes were affected too.
    I might add this annoyance occurred before I even started putting in more complex geometry.

    upload_2015-4-29_17-30-33.png
    Black spots, here seen on placeholders (though not occurring exclusively on these, depends on bake)
     
  14. dshankar

    dshankar

    Joined:
    Feb 28, 2015
    Posts:
    21
  15. Fera_KM

    Fera_KM

    Joined:
    Nov 7, 2013
    Posts:
    307
    I do not have any experience with baking in unity.
    But, but visually it looks like a UV problem.. again not sure how unity applies lightmap uv's,
    but one could try to disable automatic lightmap UV from geometry in a scene where proper UV's have been applied (i.e. no overlapping islands etc..).

    But then again, just taking a wild guess here...
     
  16. deathmoon

    deathmoon

    Joined:
    Sep 16, 2013
    Posts:
    5
    Have you generated UV maps for your project? You need to generate UVs even if they mean nothing for texture mapping.

    When you import a FBX from max without a UV map, unity tries to create one and this bug happens. At least that's what my tests indicated
     
  17. ReedSprungJr

    ReedSprungJr

    Joined:
    May 10, 2014
    Posts:
    4
    I know this thread is months old, but this is a common problem, and I think I know how to fix this. Go to tool>ProBuilder>Repair>Force Refresh Scene. It worked for me when nothing else did. It's finished baking, and the black spots are not continuing.

    Hope it works for you too.
     
  18. aimetribolet

    aimetribolet

    Joined:
    Sep 26, 2015
    Posts:
    3
    black spots aftifacts come from unity trying to lighmap several mesh faces overlapping on the same UV surface.
    In 3ds max, objects created with standard primitives like boxes, the default UVs surfaces are overlapping each on another.
    To import them in Unity, we either have to check "Generated Lightmap UV" (UVs handled by Unity) on each mesh model OR create your flatten UV yourself first in 3ds max before exporting.
    See thread: http://forum.unity3d.com/threads/so-many-lightmapping-problems-unity-5.321033/
     
    SimRuJ, anilajaho and Khyrid like this.
  19. salex1

    salex1

    Joined:
    Jul 9, 2015
    Posts:
    29
    Very interesting thread! I also have this problem, which appears quite often! The only solution that I found is that it must be done a new "clear" UV map without overlapping!!! It seems to me that this is the only solution for now. I hope this problem will be solved in the future..
     
  20. AkiraWong89

    AkiraWong89

    Joined:
    Oct 30, 2015
    Posts:
    662
    I encountered this interesting issue before.
    I'm pretty sure my custom lightmap UV is not overlapping.
    I tried some values on the lightmap baking settings.
    When I adjust AO into 0.1, it appear black spots on dark side.
    When no AO or in 1.0. Black spots totally gone.
    So how to bake AO in 0.1 with smooth result: Increase final gather value.
    It takes long time to bake as higher as the value is but problem solved.
     
  21. Firedan1176

    Firedan1176

    Joined:
    Dec 7, 2013
    Posts:
    48
    For anyone experiencing this problem
    There is a chance that your UVs are overlapping. Simply use your 3D modeling application and use their automatic mapping, such as cubic (optimal), to reshape these normals.

    You can see if you have overlapping normals by going to the Lighting tab in Unity, selecing Object, and clicking on the affected geometry. In the Lighting tab, in the preview, you should see many overlapping lines.
     
  22. Nonchecker

    Nonchecker

    Joined:
    Jul 28, 2016
    Posts:
    1
    4 me, i solved it, mesh comes from Blender and my mistake was not to make the hook at "Generate Lightmap UVs"
     
  23. DeArias

    DeArias

    Joined:
    Jan 7, 2016
    Posts:
    1
    My mesh comes from Blender too, the problem comes because I joined diferent objects with diferent UVs, I solved this making a second UV (I named it "UVMap LightMap") without overlapped faces (just making a new packing) and preserving the old one. In Unity I check Preserve UV and it makes a new pack for Lightmapping, but this time don't produce noise.
     
    theANMATOR2b likes this.
  24. WHKS

    WHKS

    Joined:
    Dec 13, 2011
    Posts:
    61
    I set fbx to generate uvs an that worked
     
  25. KarloBRIK

    KarloBRIK

    Joined:
    Aug 12, 2015
    Posts:
    4
    But what if the black cubes appear on default cubes? My walls are just white cubes with white material, and after baking they appear everywhere.
     
  26. mark-007

    mark-007

    Joined:
    Mar 4, 2015
    Posts:
    27
    Yeah, I don't buy the "badly imported object / UV's" argument at all either.. There is definitely an issue with Unity... you just have to change the lightmap resolution by 1 and the black squares appear somewhere else completely different. It's like a lottery of where they appear based on different lightmap resolution settings.
     
  27. DougyFresh25

    DougyFresh25

    Joined:
    Feb 12, 2018
    Posts:
    3
    This worked for me. I went to Quality in Project Settings and checked the texture streaming box. Looks like you have to bake it a few times OR also uncheck and check the Texture Streaming box again to actually make it work.
     
    Last edited: Aug 8, 2019
  28. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    This happened to me when the mesh didn't have proper UVs for light mapping, I solved it by enabling generate UVs for light maps in import settings of the prefab model.

    As far as I can see people have this issue for different reasons too, so it isn't guaranteed that my approach will fix your problem, however, make sure you have proper UVs for light mapping.
     
  29. Boitumelo_T

    Boitumelo_T

    Joined:
    Oct 25, 2023
    Posts:
    1
    hopefully this helps someone since this seems to be quite an issue, on, my side the problem was solved by changing the light mode from "Baked" to Realtime, after that you can change it to whatever the spots will be gone.  upload_2023-10-25_16-0-56.png