Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Possible to light bake sections of map?

Discussion in 'General Graphics' started by superme2012, Jul 14, 2015.

  1. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    The Question:

    I was thinking if I could use some kind of gizmo like a box collider to select an area to bake then it would make the process much faster as I don’t need to bake it all in one go and then repeat as it never results as expected.

    The Reason:

    I got a small map that is taking a long time to light bake. I believe it’s down to many small pieces in the environment, even tho I have used a mesh combine it still takes way to long at the lowest possible settings.

    The light is important to my development as it sets mood so the ability to tweak and change is important.
     
  2. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    I think I worked out a way to do this. It was not clear at first but if I turn off all the lightmap static option on all objects. Then enable lightmap static option on objects for the section of interest and then run a light bake that should in theory only bake that section.

    When moving to bake the next section unity should store the already finalized baked information from the previous section and won’t re-bake that data.

    This is my theory as I have not tested yet, I will post if it works as expected. Also good to mention I’m using unity 5 personal addition.
     
    Last edited: Jul 15, 2015
    Ajasmm02 and theANMATOR2b like this.
  3. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    I just did a test and can confirm my my theory is correct.

    It is possible to bake a map in sections by turning off the lightmap static option on objects. Also when focusing on a new section, unity will keep and add to the already baked data.

    I do need to test this again on the actual map, but form my test it looks sound.

    It would be nice to see the idea of a gizmo box (green box collider) that allows the ability to select an area to focus the lightbake on a specific area, but maybe something to come in the future.
     
    Ajasmm02 and theANMATOR2b like this.
  4. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    515
    Are you sure that when you do that objects that would have effected each other, if they were both light map static at the sametime, actually effect each other? (casting shadows light bouncing etc)
     
    Ajasmm02 likes this.
  5. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    Not in my case, because my design is based on rooms and I aim to bake each room in a sequence, also not going back into a previous bake and that being the real limitation. Light would not bounce much into other rooms as of doors and door ways I assume, however for large open environments this may cause a problem or will it? Who knows ha.

    What I found is that each group of objects (combined as one mesh), creates 1 job. If I had 10 of them then disabled 5 I get 5 jobs when that’s baked and I enable the other 5 I’m also getting only 5 jobs but 10 are baked.

    I do need to test this again within my scene to make sure what I’m seeing is correct.
     
    Ajasmm02 and Korno like this.
  6. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    After doing a test on my map, the speeds are better but I’m not getting the same results on saving time on ready baked areas. Some parts are getting baked again and I think it’s down to light bouncing through the map.

    But its still much faster indeed ;)

    Also one job is one light and not an object as I first thought.
     
    Last edited: Jul 16, 2015
  7. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    Just an update on this, all the small to medium sized areas baked and didn’t need to much re-baking. worked like a dream getting my results in under a min when working on any section. However when I got to my last area the largest, it started processing 23 jobs every time I hit bake.

    Im looking into this as its not clear why.
     
  8. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    Yet another update, something went wrong and the light map stopped updating. I had to re-bake the entire scene from scratch. Not impressed as I have already spent more time with lightbakes than actual production/development work.

    I would do a re-bake overnight but it’s not a flexible approach. In terms of eco-friendly I think unity’s light bake system will end the world for sure, but first driving everyone crazy!

    Any alternative lighting solutions?
     
    filibis likes this.
  9. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    515
    If its not to much, have you tried just using the realtime GI and maybe limiting shadow distance? (works well for indoor games - where you have rooms with one or two lights only). You still have to do the bake (so the realtime GI has its scene info for light bouncing) but it will be much quicker. Use light probes for dynamic objects. If it is an outdoor scene not sure really....mixed mode lights are supposed to be the solution for that dynamic shadows near the camera and lightmapped stuff far away, dynamic shadows for dynamic objects and lightmap stuff for static stuff. BUT they are broken at the moment....

    If you really need baked GI - I have heard that breaking down geometry into smaller pieces improves speed - as each peice will only effect a few pieces near it. A giant piece would effect lots of geometry (think about your floor). Apart from that - play with the settings and keep them low when developing. When you finish you can up them all for a huge final bake (also borrow some NASA computers....)
     
  10. kemalakay

    kemalakay

    Unity Technologies

    Joined:
    Jul 12, 2016
    Posts:
    224
    First of all, most of the distant shadow issues should have been resolved with the introduction of new mixed light modes in 5.6. Shadowmask modes allow you to have baked shadows beyond `Shadow Distance` when you use mixed lights and if you want realtime shadows from both static and dynamic objects within the shadow distance, then you can use Distance Shadowmask mode. Besides indirect illumination, light probes are also necessary for occlusion (i.e. dynamic objects receiving shadows from static objects)

    On the other hand, the introduction of Progressive Lightmapper (PLM) should facilitate your workflow for baking as you can now immediately start to see the preview of your bake in the scene view. New light modes are still not supported yet for PLM but it's almost there.

    Also, I have to correct one wrong assumption about baked GI for others. Having smaller pieces or giant pieces does not matter for baking speed. What matters is the density of texel resolution. Globally, you can change the resolution of your lightmaps under Lightmapping Settings in Lighting window. And you can use `Scale In Lightmap` parameter under Mesh Renderer component to adjust the resolution of your geometry locally. In addition, you can use `Baked Lightmap` debug visualization mode and enable checkers to see how dense your geometry is. In Enlighten, this also affects the clustering resolution and higher values can drastically increase the baking time. Please consider adjusting the resolution of your geometry based on your needs as that alone can hugely affect your bake times.

    Thanks
     
    theANMATOR2b and filibis like this.
unityunity