Search Unity

light map max at 1k?[solved]

Discussion in 'Editor & General Support' started by cherub, Aug 5, 2010.

  1. cherub

    cherub

    Joined:
    Apr 26, 2006
    Posts:
    493
    just wondering if the max lightmap size is 1024x1024.

    the resolution setting doesnt get any finer after a certain value.
     
  2. robert

    robert

    Moderator

    Joined:
    Dec 21, 2008
    Posts:
    265
    1024x1024 is the default max atlas size. Since a single object can only occupy one lightmap, once it fills up the entire 1k lightmap, you've reached the max resolution for this given object.

    If you really need higher max atlas sizes, you can change them from scripting using LightmapEditorSettings.maxAtlasWidth (and Height) up to 4096x4096. Just remember to adjust your texture import settings on the lightmaps, because you'll probably still have them at max 1k.

    For terrains you can directly specify lightmap size up to 4096.
     
  3. cherub

    cherub

    Joined:
    Apr 26, 2006
    Posts:
    493
    thanks! I knew there was a way.

    excuse my ignorance. how would you get that to happen?

    i dont know anything about editor scripting.
     
  4. cherub

    cherub

    Joined:
    Apr 26, 2006
    Posts:
    493
    im sure theres a way to choose the size when run, but im not quite savy enough yet..:)


    Code (csharp):
    1.  
    2. @MenuItem ("Cherub's/LM Size")
    3. static function SetLMSize()
    4. {
    5. LightmapEditorSettings.maxAtlasWidth = 2048;
    6. LightmapEditorSettings.maxAtlasHeight = 2048;
    7. }
     
  5. robert

    robert

    Moderator

    Joined:
    Dec 21, 2008
    Posts:
    265
    Code (csharp):
    1. using UnityEditor;
    2.  
    3. public class MaxAtlasSize : EditorWindow
    4. {
    5.     int[] kSizeValues = { 512, 1024, 2048, 4096 };
    6.     string[] kSizeStrings = { "512", "1024", "2048", "4096" };
    7.  
    8.     void OnGUI()
    9.     {
    10.         LightmapEditorSettings.maxAtlasHeight = EditorGUILayout.IntPopup("Max Atlas Size", LightmapEditorSettings.maxAtlasHeight, kSizeStrings, kSizeValues);
    11.         LightmapEditorSettings.maxAtlasWidth = LightmapEditorSettings.maxAtlasHeight;
    12.     }
    13.  
    14.     [MenuItem("Utilities/Max Atlas Size")]
    15.     static void Init()
    16.     {
    17.         EditorWindow window = EditorWindow.GetWindow(typeof(MaxAtlasSize));
    18.         window.Show();
    19.     }
    20. }
    (just remember to bump max size in the texture importer as well, if you're going above 1024)
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,723
    Why are the near and far lightmaps the same resolution? Doesn't it make sense to have the near ones at a higher res than the far?... If you have a normal shadow distance, doesn't mip-mapping kick in anyway? So you don't even ever see the highres far one, but it does get loaded (and baked) at the high res.
     
  7. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    You need the lightmapper open to use it, I think.
     
  8. frankrs

    frankrs

    Joined:
    Aug 29, 2009
    Posts:
    300
    I think I figured it out. I just rendered again after changing the import settings on the map after the fact.
     
  9. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    You shouldn't delete your posts after someone has replied to them, considered bad form and can cause confusion (now it looks like I'm replying to AcidArrow when I wasn't doing).
     
  10. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    I am trying to use the code from robert and the menu item is showed but not the size options.
     
    Last edited: Oct 19, 2010
  11. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Sorry for the Bump but does someone have an explanation for a studpid artist? Please?

    I also can see the menu Item but I can't change the resolution for any of the Objects.
    I select a Mesh but all I get is:
    What am I supposed to do?

    [edit] I found the solution, yesterday.
    Don't know why the script itself won't work but other than the menu entry itself I just didn't get the menu to chose the actual resolution from. So I did it the brute force way and simply added a menu with 4 items: 512, 1K, 2K, 4K.
    In case anyobody else encounters the problems I did: here's the code.

    Code (csharp):
    1. using UnityEditor;
    2.  
    3. public class AtlasSize_512 : EditorWindow
    4. {
    5.     [MenuItem("LightmapSize/AtlasSize_512")]
    6.     static void Init()
    7.     {
    8.         LightmapEditorSettings.maxAtlasHeight = 512;
    9.         LightmapEditorSettings.maxAtlasWidth = 512;
    10.     }
    11. }
    12.  
    13. public class AtlasSize_1K : EditorWindow
    14. {
    15.     [MenuItem("LightmapSize/AtlasSize_1K")]
    16.     static void Init()
    17.     {
    18.         LightmapEditorSettings.maxAtlasHeight = 1024;
    19.         LightmapEditorSettings.maxAtlasWidth = 1024;
    20.     }
    21. }
    22.  
    23. public class AtlasSize_2K : EditorWindow
    24. {
    25.     [MenuItem("LightmapSize/AtlasSize_2K")]
    26.     static void Init()
    27.     {
    28.         LightmapEditorSettings.maxAtlasHeight = 2048;
    29.         LightmapEditorSettings.maxAtlasWidth = 2048;
    30.     }
    31. }
    32.  
    33. public class AtlasSize_4K : EditorWindow
    34. {
    35.     [MenuItem("LightmapSize/AtlasSize_4K")]
    36.     static void Init()
    37.     {
    38.         LightmapEditorSettings.maxAtlasHeight = 4096;
    39.         LightmapEditorSettings.maxAtlasWidth = 4096;
    40.     }
    41. }
     
    Last edited: Dec 1, 2010
    Pulov likes this.
  12. Crayox

    Crayox

    Joined:
    Dec 21, 2014
    Posts:
    9
    robert, can you tell me where to adjust texture size for my lightmaps? I just can't find it. I can see the one for my normal textures, but after using this script I generated 4096 maps but my Lightmapper uses 1024 maps still.
    thx
     
  13. Crayox

    Crayox

    Joined:
    Dec 21, 2014
    Posts:
    9
    Oh, oups...I found them in one of projects directories.
     
  14. work7579

    work7579

    Joined:
    Apr 27, 2020
    Posts:
    1
    Hi, guys.
    Sorry by necroposting, but I'm still usung Unity 3.5.7, because newer versions (starting from Unity 5 and higher) in the finished project do not give the performance that I would like to get as a result and on my opinion, Unity 3.5.7 still have a fastest render engine.
    I read the topic completely, but the scripts above do not give any result and I still can not increase the size of lightmaps :(
    Yes, when I add a script to the project, the item "LightmapSize" appears in the panel and I can choose from 512 to 4096, but nothing changes when I press "4096" and when baking a lightmap texture, the size will still remain 1024.
    When I add a script to any mesh, as described above, I get the error "NullReferenceException: Object reference not set to an instance of an object":(
    What is the sequence of actions in using this script?

    Hi, Crayox.
    My Lightmapper still generate 1024, not 4096 maps...
    What am I doing wrong?

    Can you tell me exactly where?
     
    Last edited: May 26, 2020
  15. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    I have the same problem
     
  16. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    I think unity decide instead of you about max res size for this scene.