Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Static Batching cause meshes to be scrambled

Discussion in 'Editor & General Support' started by Freaking-Pingo, Mar 12, 2015.

  1. Freaking-Pingo

    Freaking-Pingo

    Joined:
    Aug 1, 2012
    Posts:
    310
    After uploading my project from my Mac to my PC, meshes making use of static batches becomes scrambled followed with an error.

    Removing the static batch mark, removes the issue. We are using Unity 5.0 The issue only occurs on my friend's and I's Windows machine. He is sitting on a Windows 8 machine, I sit on a Windows 7. The problem doesn't occur on both our Macs. I tried re-opening Unity, and tried reimporting all assets.

    With Static Batching OFF


    With Static Batching ON
     
    Last edited: Mar 12, 2015
  2. Freaking-Pingo

    Freaking-Pingo

    Joined:
    Aug 1, 2012
    Posts:
    310
    The problem is still persistent, we can't seem to find a way to fix it. We might consider switching to a new project, and see if that helps
     
  3. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Looks like a genuine edge-case under-the-hood "number foof" - I would report that.

    (after testing on a new project with a much simpler asset set)
     
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Yes, please file a bug report.
     
  5. Freaking-Pingo

    Freaking-Pingo

    Joined:
    Aug 1, 2012
    Posts:
    310
    First time I am filing a bug. 680523
    I were not able to reproduce the problem, but I attached our project in the bug report, so hopefully that can help you narrow it down.
     
    Last edited by a moderator: Mar 14, 2015
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Edited to provide just the number, otherwise people can see your full history of fogbugz and you may or may not want that :)
     
    twobob and Freaking-Pingo like this.
  7. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hmmm sounds like it could in fact be asset related then huh...
    Either way sounds like a good edge-case to at least check is "covered" in a sensible amount of cases.
    Shouldn't balk basically :p
     
  8. Freaking-Pingo

    Freaking-Pingo

    Joined:
    Aug 1, 2012
    Posts:
    310
    I believe its a bug within unity. We have previously had the sameasset as static batched on our windows machines without problems, but we did a bunch of work on our macs, and we are not able to identify the differences between when it worked and now.
     
  9. Deleted User

    Deleted User

    Guest

    Well, a skipped vertex index would probably result in this sort of scrambling if unchecked, with triangles being built from points that are supposed to belong to other triangles. (if the verts are still in the same place and the first few hundred tris look fine)

    So while we don't know yet if it's a bug or just a bad mesh, it's certainly not handled too gracefully.
     
  10. benblo

    benblo

    Joined:
    Aug 14, 2007
    Posts:
    475
    Are you using a custom vertex shader with vertex displacement? The object matrix is different if you're batched, I once got screwed over because of that.
     
  11. mcapousek

    mcapousek

    Joined:
    Jan 11, 2013
    Posts:
    9
    Hi, I expirienced something similar - when i pressed play button static meshes in scene got corrupted. Clearing lightmap data helped me.
     
    Harold_83 likes this.
  12. Deleted User

    Deleted User

    Guest

    I just got this bug today, and after some fiddling I found the cause. It was triggered by changing the Smoothing Angle slider on an imported mesh designated as batching static.

    As we all know, changing the smoothing angle creates and removes vertex splits, changing the amount of vertices on a mesh. Now guess what would happen if someone forgot to update the vertex count of the referenced meshes in some serialized data, and tried to build a supermesh for batching purposes from that data... and yes, the only scene affected by this had a dynamic lightmap.

    Changing the smoothing angle back to the value present at the time of making the scene has fixed it. Changing the angle to other values scrambled the hell out of the lighting on that mesh, even without batching.

    I'm still having some errors related to static batching, like a few random triangles having broken UVs from time to time (no error message), but for now I'll assume it's caused by the same thing.
     
  13. Sparrowfc

    Sparrowfc

    Joined:
    Jan 31, 2013
    Posts:
    100
    I've just met the same problem. Thanks to this thread, just clear the baked lightmap throught Lighing Window, and then revert those lightmaps through svn or manually should fix this bug.
     
    Gametyme, Barry100 and Marble like this.
  14. Harold_83

    Harold_83

    Joined:
    Nov 25, 2014
    Posts:
    44
    I searched and searched for an answer and got lucky and you have the best answer. The key search was scrambled.
     
    Barry100 likes this.
  15. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    584
    Remove your light map and then back it again, that will solve your issue ;)
     
    r618 likes this.
  16. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    Just encountered this problem as well and don't have a lightmap baked that I can clear. Does anyone happen to have any other solutions?
     
    baci likes this.
  17. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    We had this "venom spider web effect" of a scrambled mesh too. Clearing lightmap bakes and rebaking solved it for us as well. At least a solution to fix it exists.
     
  18. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    i done the lightmaps too.. fixed it
     
  19. whileBreak

    whileBreak

    Joined:
    Aug 28, 2014
    Posts:
    289
    Hi had the same problem, and thanks to this thread I got to solve it. It isnt actually the lightmaps. The problem is in the convined meshes that the baker makes from your objects. If you check the automatic Baking it should remade what it needs without loosing the other longer to compute baking data. That solved it for me.
     
    Thomas-Mountainborn likes this.
  20. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    Here's another spin on the problem: Recall that lightmaps are per-scene. We are using Advanced Additive Scenes for scene management. We baked our environment SubScene and then our main (container) scene (errantly) with the environment SubScene enabled. So the environment was represented twice in the combined lightmaps when the scenes were loaded additively. Boomsville (tm).
     
  21. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    Having to rebuild lightmaps everytime a mesh gets modified is really annoying. I haven't tried the solution with setting the lighting window to auto, since last I checked, there's a bug where loading a scene that was set to auto means no lighting information is loaded.
     
  22. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    I am seeing this error in Unity 5.3.2p2, every time I modify a mesh that is in a prefab marked static. Clearing GI / lighting does not fix the issue - only deleting the prefab from the scene and then creating it again from scratch fixes it, which you can imagine is not a solution when I have hundreds of prefabs.