Search Unity

Question Calculating Scale in Lightmap

Discussion in 'Global Illumination' started by sstrong, May 22, 2020.

  1. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    I have a mesh that has been clamped to 512x512 - I'm assuming this is the Realtime Lightmap. I'm also baking with GPU Lightmapper (in this example in 2018.4 LTS).

    In the mesh renderer the Realtime Lightmap says "Instance Resolution" of 512x512 and the "System Resolution" is 508x506.

    Currently the "Scale In Lightmap" for this is mesh is 1. I'm assuming I should scale this down to something below 1. What is the correct calculation to determine what this scale value should be? On the "Lighting" tab, my "Lightmap Resolution" is 40 with a "Lightmap Size" of 1024.
     
  2. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    103
    Hi sstrong!

    Lightmap resolution refers to how many texels you have per meter (or "world unit" if you prefer). The "right" resolution depends on your circumstances. If you increase the resolution you get higher quality, but you also use more resources. Therefore it is a trade-off.

    A mesh's effective lightmap resolution is [Lightmap Resolution] * [Scale in Lightmap]. If for example "Scale In Lightmap" = 0.5 and "Lightmap Resolution" = 20, then the effective resolution is 0.5 * 20 = 10.

    So you have several ways to tweak the resolution. If you want to increase/decrease resolution for all meshes you increase "Lightmap Resolution" (in Lighting window). If you want to increase/decrease only resolution of a single MeshRenderer, then you can use "Scale in Lightmap" for that renderer.

    I recommend you read this post which discusses how Scale In Lightmap and Lightmap Resolution work together.
     
  3. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    Yes, I understand the relationship between Scale in Lightmap and Lightmap Resolution. What I'm having trouble with is the error message:

    "In the mesh renderer the Realtime Lightmap says "Instance Resolution" of 512x512 and the "System Resolution" is 508x506."

    How do I calculate the value of "Scale In Lightmap" to resolve this?
     
  4. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Instance Resolution and System Resolution are properties of the precomputed realtime GI system (Enlighten). These sizes are not affected by the baked lightmap size. Sounds like you are using both realtime and baked GI at the same time. If this is intended you can adjust indirect resolution to make global changes or use lightmap parameters to tweak groups of renderers.