Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity 2020.1 Lightmap and LODs - how does it work? How to fix them?

Discussion in 'Global Illumination' started by Hannibal_Leo, Sep 3, 2020.

  1. Hannibal_Leo

    Hannibal_Leo

    Joined:
    Nov 5, 2012
    Posts:
    219
    I think, within the last month, I hit the "Generate Lightning" button more often than the semicolon key - and I am a programmer ... (who has to do lightmapping now because we are just two guys working on this game and the leveldesigner is busy doing .. well .. leveldesign things)
    While the genrated lightmap gives pretty decent results overall, it works horribly on LODs.

    Usually LODs, with the dithering fade HDRP provides, are completely invisible (awesome job, Unity Team! it works absolutely smooth) but once I bake the Lightmap, all LODs have a different brightness.
    LOD0 : grey
    LOD1: almost white
    LOD2: black

    I tried lightprobes, changing the lightmap scale, using models with correct UV2, read a lot, placed lightprobes everywhere, added reflection probes, tuned the lightning settings up and down, created Custom Lightmap Parameters and tweaked them ... it seems impossible to fix this issue.

    The one big question (besides how to fix this) is: Why calculating the lightmap for LOD >0 at all?
    It shouldn't matter if UV2 is setup correctly, the texels with the required lightning informations are already there .. it should be possible to simply find the nearest 3-4 texels on LOD0 and copy their information onto lower LODs, why would you start shooting new rays if the LOD-Models are basically at the same place?
    This would also gurantee that lower LODs don't change their brightness so drastically and reduce computation time extremly..

    But ok, my main question is how to fix the Lightmaps on lower LOD levels?

    Also ... some of the Docs say that lower LODs don't get any lightmaps at all and just use lightprobes but I think that are outdated informations.


    Here is an example video (ignore the music which was running in the background and got recorded by OBS as well as my mouse-movement which is showing that the light probe-setup yields better results in this specific case (but it does not work so well in outdoor areas))



    PS: the video is just an example, but it happens everywhere, on Building-Walls / -Floors, Props, Stones, .. I can't change all the 2000 assets we use in our game
     
    Last edited: Sep 3, 2020
  2. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    168
    Which backend are you using for baking? CPU lightmapper, GPU lightmapper or Enlighten?
    Can you post a screenshot of the mesh renderer of the lodded object?
    As for why lods even get their own texel space in the lightmap, Unity allows you to completely switch objects in various lods. This flexibility however prevents us from dictating that lods must always be projection compatible.
     
  3. Hannibal_Leo

    Hannibal_Leo

    Joined:
    Nov 5, 2012
    Posts:
    219
    I am using ProgressiveCPU Lightmapper in HDRP in Unity 2020.1.2f1
    upload_2020-9-10_20-11-41.png

    Screenshot: Not the one from the video, but one thats also "flickering" (switching to almost black/white on lower LODs)
    upload_2020-9-10_20-10-58.png


    If it is in theory possible to use the parents-texel "colors" (lightmap information or however this is called), it would be awesome if this could be implemented with some kind of enum-selection on the LOD component
    Something like:
    ShareLightmap Setting:
    - Use Lightning Settings Default
    - Individual Lightmap Calculation
    - Use L0 Texel Information

    and maybe: Share Lightmap Space, so if there is a proper UV2 setup (UV2 of L1, L2, .. share the same space as UV2 of L0), the childs can use the Lightmap of L0.

    But thats a feature request I guess and won't solve my problem right now.
     
  4. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    168
    The "Scale In Lightmap" on the mesh renderer rather aggresively reduces the scale for each lod (halving it at every step). For lower lods you can end up with just a few texels in the lightmap, despite the object being quite large.
    As a baseline what you can try is set the lightmap scale on each lod to 1.0, bake and compare the results (that is each mesh renderer assigned to a lod has this parameter, so if you have 5 lods with 5 unique meshes per lod, you need to modify all 5). You can then start lowering that scale.
    The sample counts that you're using for indirect (128) and environment (16) are extremely low as well. To get a more representative result try setting them to something like 2048 for both. For final quality you'd crank them even higher.
     
unityunity