Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Struggling with lightmapping - atlas size limit (Unity 5 18b)

Discussion in 'Unity 5 Pre-order Beta' started by LadyAth, Dec 31, 2014.

  1. LadyAth

    LadyAth

    Joined:
    Jan 17, 2014
    Posts:
    158
    Firstly, happy new year to everyone :)

    And then there is my problem: I spent countless hours creating an outdoors scene (512x512) which by nature of the area, has a lot of vegetation (used Unity terrain for trees, grass and bushes). I've added models with LOD versions where possible, used tools like ProDrawCallOptimiser, restricted max texture sizes for just about everything where possible and tried to keep the scene as uncomplicated as possible. It has two water pools (pro) and a waterfall (purely fx). There are some other fx features like will-o-wisps, but they are just colored dots flying around. All trees are made with the unity tree creator (Asset store bought). Removed mesh colliders and using box or capsule colliders for everything. The scene itself has 'portals' to enter other areas like village, beach, graveyard, etc and I've not been able to think how I can make it smaller unless I cut on the size (though I thought 512 is not too big??).

    Everything works ok and getting FPS of 40-50 throughout the scene after a bit of tweaking. Happiness. BUT - problem comes when I try to bake. I switched off the real-time baking (Unity 5) because of it hitting my laptop too hard when trying to edit a scene and Unity constantly re-updating. So when I try to bake manually, it tells me that I cannot bake because my terrain's object size in lightmap has reached the max atlas size. And this is on Default-VeryLowResolution. Scale is currently 0.128. If I drop it to 0.042, it bakes, but looks HORRID.

    Tried linear instead of gamma. Also increased atlas size to 4096. Changing things like the baked resolution under Baked GI, turning off fog, using directional lighting, checking all objects are static...nothing has made a difference.


    So my question is: what are my options? What should I do to bake high quality scenes? Anyone have pointers on what settings I should configure in the Lighting window? Is there something I must be sure to check on the assets I am using? Note: I suck at graphics, all Asset Store bought.

    I tried Google and searching on the Unity forums, but either I am searching for the wrong keywords or I have seriously mucked up something. *sigh*

    Advice would be very appreciated - as it stands it looks like I am going to have to trash that scene :(

    Just checked another scene of mine before posting and it is only 200x200, no Unity terrain models, but about 60-odd models of trees, gravestones and other graveyardy stuff. SAME problem :(
     
  2. seattlebluesky

    seattlebluesky

    Joined:
    Sep 2, 2014
    Posts:
    170
    The Beta lighting system definitely is having issues with terrains for many people. If you mark all terrain game objects as non-static in your scene and then bake, not what you ultimately want I know, does it succeed? But then I see the comment on no terrain models but a lot of other meshes and that has the problem. Curious. Do these same scenes bake in Unity 4.6 using Beast?
     
  3. LadyAth

    LadyAth

    Joined:
    Jan 17, 2014
    Posts:
    158
    I've not tested these scenes in 4.6 since I started a rebuild on my project using only 5 and never had much joy in opening projects with older versions prior to Unity 5.

    Did some more testing:
    If I remove Lightmap Static from terrain, the error disappears - but if not set I'm not sure if there would be any benefit in a bake.

    What is interesting with rendered objects is that the prefabs of trees (also made with the Unity 4 tree creator and assets from the store) and a couple of mountain rock prefabs give the same error. It maps to a default lightmap scale of 1 and need to be dropped to 0.57 before the error disappears.

    What sets a model's lightmap scale? Is it determined by something? Not all rendered objects are at 1 - some have defaulted to 0.5 or 0.25 instead.

    Busy trying another bake now with terrain lightmap static disabled and only trying with rendered objects (after fixing the scale for all the complaining items). Will post the outcome.

    And thanks for the response :)
     
  4. seattlebluesky

    seattlebluesky

    Joined:
    Sep 2, 2014
    Posts:
    170
    Yes, for sure there's little value in not having a light-mapped terrain especially if you have a lot of lit static objects placed on it. I'm not savvy enough w/ Unity to know what sets a model's light-map scale implicitly. I know that you can of course set it explicitly via the Object tab in the Scene inspector.
     
  5. LadyAth

    LadyAth

    Joined:
    Jan 17, 2014
    Posts:
    158
    14 hours later and was still trying to bake - ended up cancelling the process. So it seems I'll be rebuilding scenes to try and make it even smaller, but would like to try avoid running into this problem for the next time. Thanks for pointing out that I can find it in the scene inspector. I'll do some more searching on Google on lightmap scale and UV settings. There must be something off with my build that is causing such headaches with baking.

    Any additional tips, warnings, advice, etc on how to succeed in good quality baking would be very useful to me, esp when using asset store items which might or might not be optimised. For example: is it bad to change textures from their default sizes to lower max resolutions (terrain or plants, left other object textures alone)?
     
  6. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Unity 5 is still in beta. Baking terrains is pretty much impossible at the moment. I encourage you to turn off lightmap static on your terrain. I'm hoping in beta 19 or beta 20 lightmapping will actually work for terrains, but it might be later. Either way it will be fixed by the time Unity 5 is released. If you can hold off releasing your project until the lightmapping is fixed that would be the best solution. Just wait. Lightmapping isn't that essential if you're still in development.

    In the meantime you can make an additional lightmap paremeter where you set everything even lower. Also set the terrain
     
  7. LadyAth

    LadyAth

    Joined:
    Jan 17, 2014
    Posts:
    158
    Aaah thank you for that. I understand that there will always be issues with beta and I am still learning through my project and nowhere NEAR any kind of release. What I was worried about was that I was mucking up on the lightmapping. I've seen the threads about the real-time issues and lagging the editor, but not much in terms of terrain challenges. Still an opportunity to get into a habit of optimised scene building so that when Unity 5 is released, I am prepared with well-baked scenes. I have noticed some of the assets I am using have some challenges and I am busy with a clean-up and doing stuff like setting Unity to do the UV mapping on model import, etc. Also trying to avoid using terrain textures that come out with a 2048 max size (on models I am mode forgiving). So please, any other tips would be much appreciated.
     
  8. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    Terrain baking is indeed slower than expected, but with the right settings it should finish within a reasonable time.

    One thing to note is that the bake (so the process that produces lightmaps that don't change at runtime) relies on the precompute (the process that calculates data that allows Enlighten to efficiently calculate GI at runtime).

    So the precompute always runs first and only then the bake runs.

    If you have an issue with baking lightmaps for terrain taking a lot of time, I would advise you to first turn off Baked GI (so that you can narrow down the scope of the slowness) and then make sure that the realtime resolution you actually get on your terrain is as low as it can possibly be, while still giving you good indirect lighting.

    The final resolution for realtime GI is the result of multiplying:
    • Realtime Resolution in the Scene tab of the Lighting window
    • the Resolution in the Realtime GI group of Lightmap Parameters
      • either those set in General GI in the Default Parameters slot (if non-default)
      • or the override set on a particular object in the Object tab of the Lighting window
    The key is to look at the various GI debug scene views (dropdown in the upper left corner of the scene view) as they show you data that Enlighten has finished calculating at a specific point in time.
    They are lined up in the order in which they finish in the pipeline, so check the first view (charting aka UV charts aka UV islands) first. It shows you the exact texel size at which Enlighten is calculating it's data and for a terrain those texels should be biiiig.
     
    seattlebluesky likes this.
  9. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    Also, Scale in lightmap only affects the bake, not the precompute. The resolution for the precompute can only be tweaked as described above.