Search Unity

Custom Lightmap packing

Discussion in 'Global Illumination' started by Inter-Illusion, Feb 7, 2018.

  1. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    I'm looking to modify the way Unity packs each of the Renderers into the bakd lightmap (not runtime).

    It seems that when executing the Lightmap bake, unity automatically uses the "Scale In lightmap" property to modify the LightmapScaleOffset property, and then does a packing of all Renderers into as many lightmaps as needed.

    1- Is it possible to make unity skip the LightmapScaleOffset generation and atlas repacking?
    I want to generate a custom LightMapScaleOffset (using a custom inspector script), and force unity to use that without repacking them.
    I tried modifying that variable just before baking, but unity changes its value as soon as the baking starts.
    It will be of great help if there is a variable somewhere (even if had to be accessed though reflection) that disables the repacking!

    2- Alternatively, is it possible to just run the repacking without doing the baking?

    Ideally, I will generate the LightMapScaleOffset, but if that's not possible, its there a method to perform just the repacking.
    I want to modify the "Scale In Lightmap" and do several tests to see what values are the best for each level.
    Its there an exposed method that selects into which Lightmap each renderer is placed, and repacking them?

    3- There used to be a property named LockAtlas that skipped the repacking.
    That its now deprecated, but is there a workaround to access that same functionality?

    Thanks,
    Frank
     
    Last edited: Feb 7, 2018
    AcidArrow likes this.
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,741
    Unless something changed really recently, I think it's no for all 3 of them (but hopefully I'm wrong).

    I know I have asked for 2 many times in the past. At one point a dev said something about exposing the packing API but AFAIK that hasn't happened.
     
  3. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Been looking over the ILSpy and I guess you are right, at least I don't see any method I could call, and even the LockAtlas property its now empty.

    Nonetheless, it will be great if someone from Unity could give an official answer.
    Also, it will be good to know if there are plans to bring the LockAtlas property back or something similar.
     
  4. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
  5. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Well, it seems that no one from unity is actually reading this forum :-(
    Its a shame, as a proper answer from them will actually help a lot!
     
  6. kemalakay

    kemalakay

    Unity Technologies

    Joined:
    Jul 12, 2016
    Posts:
    224
    Hey @Inter-Illusion

    We're reading it, just not very frequently nowadays due to GDC. @AcidArrow is right with his first reply, we've plans for these tasks later this year (to improve packing)

    Thanks