Search Unity

Any way to use fixed size lightmaps?

Discussion in 'Global Illumination' started by AlbertoVP, Sep 23, 2019.

  1. AlbertoVP

    AlbertoVP

    Joined:
    Dec 6, 2016
    Posts:
    42
    Is there any way to use a fixed resolution for Unity objects? That you can say to an object "you occupy 256x256 of the lightmap" and not be depending on that black box that is the lightmaps system that brings unity by default?
     
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Unfortunately, you cannot specify lightmap resolution per object. However, you can specify lightmap scale in the Mesh Renderer component per-mesh basis.

    In addition, if you are using Unity 2019.2 or newer, you can now specify the max number of lightmaps your object(s) can occupy. Simply create a Lightmap Parameters asset, and enable Limit Lightmap Count flag.

    Screenshot 2019-09-23 at 11.40.27.png
     
  3. AlbertoVP

    AlbertoVP

    Joined:
    Dec 6, 2016
    Posts:
    42
    What is the problem to implement fixed lightmap space?

    Currently there is a formula based on the texel size of the map and the scale of the object that ends up giving a size in the lightmap. What is the problem of adding an option to override all that calculation and put directly a "this object occupies 128x128 in the lightmap".

    The current system is a huge problem because almost all lightmaps remain unused completely because as the space occupied by the objects are not multiples of 2 it is not possible to mount all objects in a texture of 1024 or 2048 correctly. It also eliminates any possibility of making a lightmap exactly and avoiding bleeding.
     
  4. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    I understand your frustration regarding the current system, but rest assured that we are making improvements to it. One of the improvements that will land in the near future is overlap free packing. By indicating the minimum lightmap resolution and minimum object scale in the mesh importer settings, our packing algorithm will guarantee overlap free packing, as long as that "contract" is not broken by a user.
     
  5. AlbertoVP

    AlbertoVP

    Joined:
    Dec 6, 2016
    Posts:
    42
    It has nothing to do with what I'm saying, nor will it solve any of the problems I said in my message. When what is asked here is something so simple to implement.

    ---Give the option to make the lightmap the way we need. No more automations that don't work or do what I need.---

    Sometimes I wonder when you intend to give users the ability to have control over their projects.
     
  6. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    103
    I think
    kristijonas_unity was solely referring to the fact that you mentioned "bleeding". I assume that by "bleeding" you are indeed referring to unintended cross-chart information transfer due to GPU bilinear filtering. This issue is in fact somewhat alleviated by the upcoming improvement to the Mesh Importer (as explained above).

    Thank you for your feature suggestion. I agree that it, in some settings, would make sense to have such a setting. However, just because the feature logically seems simple, that does not necessarily mean that it is easy to implement in an engine like Unity that already supports a wealth of different workflows. Even the simplest change can sometimes cascade into unexpected areas in surprising ways. On top of that you have to write automatic tests (to ensure no regressions), you have to perform manual Q/A verifications, maybe you need to consider UX conformity, you have to manage source control processes with code reviews, etc. All this adds up, even for small changes. At least that is my experience when working with large and complex software code bases with millions of lines of code.

    Additionally, we have many different users to cater for. Some people want manual workflows and tight control while others prefer full automation and ease of use. These two priorities can often contradict in ways that make the design of Unity difficult when trying to make as many users happy as possible.

    Also, when you have thousands (or maybe even millions) of users who all want "just one simple change" that adds up. Which of these do you pick? Due to the above mentioned reasons, we cannot implement everything any users ask for. Ideally, you'd go for the features that the most people request. This inevitably leaves some users unsatisfied though we are trying our best to avoid this.

    To be clear, the above statements are all just based on my personal observations and experiences as a software developer. I know this doesn't address your wish directly, but I hope it at least makes you appreciate that your feature request isn't necessarily as simple as just changing a few lines of code. At the very least, I can assure you that we are taking your request into account when prioritizing our work going forward.