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. Dismiss Notice

Custom lightmap packing in Unity?

Discussion in 'Global Illumination' started by screenracer, Nov 24, 2020.

  1. screenracer

    screenracer

    Joined:
    May 9, 2011
    Posts:
    112
    Are we able to manually move & scale the lightmap packing around to fill the gaps and holes? (To clarify, I just want to move the square per each object unwrap, not the pack within the object.) I'd just like to click on on a square, move and scale it around to better fill the existing texture space and re-light the scene using that edited unwrap pack. Is there a 3rd party plugin to do this or a hidden toggle I'm missing in Unity?

    When I adjust the "lightmap resolution" just slightly larger it adds another lightmap to the scene. I'd like for our scene to only use one lightmap in our mobile game.
    upload_2020-11-24_1-20-46.png
     
  2. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    99
    Hi screenracer. Unfortunately, it is not possible to manually control the positioning of each "object square" in the lightmap.

    However, we have another feature that may address your need: Limit Lightmap Count. This feature was made specifically for the use-case of mobile games where you want to limit the number of lightmaps generated. It works by scaling down your objects (in the lightmap) iteratively until they eventually fit into the desired number of lightmaps. Note that this scaling down may affect the number of texels per meter, and consequently, the overall quality. You can read more about it in the manual (search for Limit Lightmap Count).

    Here I show how to use it:
    limit-lightmap-count.gif

    Once you have set a lightmap limit, you can continue to work with the "Scale in Lightmap" (MeshRenderer) setting to change the size of objects' square in the lightmaps relative to each other.

    On a more general note, it is no secret that Unity's packing and unwrapping procedures are in need of some care. For example we need tighter packing and we need to guarantee no texel bleeding between charts. We have several proposed solutions/improvements lined up but we haven't yet been able to actually set aside time to work on it (except for the Auto Pack Margin feature and the Limit Lightmap Count feature). I cannot promise anything, but I have a hope that we can set aside time for these much-needed improvements in 2021.
     
    Last edited: Dec 3, 2020
  3. ivank

    ivank

    Joined:
    Nov 16, 2013
    Posts:
    97
    Hi @rasmusn, would not it be good to provide possibility for Unity to allow/read lightmap mapping created in external 3d modeling applications, which have anyway mapping tools far better than Unity has (and will have in foreseeable future]?