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

Bug Lightmapper uses LDR instead of HDR Skybox Texture for Baking on Android

Discussion in 'Global Illumination' started by LudwigVRtualX, Sep 8, 2023.

  1. LudwigVRtualX

    LudwigVRtualX

    Joined:
    Oct 15, 2018
    Posts:
    11
    I am trying to bake hard sunlight from an hdr image on android but it looks like the lightmapper uses the compressed ldr image for the bake instead of the original hdr image. I have tried the different compression settings on the image but could not find one that allows me to bake hard light and shadow from an hdr image. This is not an issue with the compression of the lightmap as i can bake hard shadows with a directional light.

    I specifically want to bake from the hdri instead of using any artificial lightsources in the scene.

    The two images below show the difference between the correct bake on Windows and the incorrect bake on Android build targets.

    Obviously its super impractical to switch the build target for each lightbake.

    Does anybody know how to bake hard lighting from an hdri while staying on Android build target?

    Thank you for your work!




    I did this test on 2022.3.7f1

    Windows:
    upload_2023-9-8_13-6-41.png

    Android:
    upload_2023-9-8_13-10-10.png
     
  2. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    248
    Check the "HDR Cubemap Encoding" option in Project Settings, under "Other Settings/Rendering" in the "Player" tab.

    Roughly:
    Low Quality = dLDR
    Normal Quality = RGBM
    High Quality = Full HDR

    On older versions of Unity, this was instead controlled by the "Lightmap Encoding" setting which lives right next to it, just in case anyone finds that info useful.

    On Android specifically I believe there is an additional setting influencing texture format. It's listed as "Texture compression format" on this page https://docs.unity3d.com/2022.3/Documentation/Manual/class-PlayerSettingsAndroid.html. Might have to fiddle with that too, I'm not sure.
     
    Last edited: Sep 8, 2023
  3. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    248
  4. LudwigVRtualX

    LudwigVRtualX

    Joined:
    Oct 15, 2018
    Posts:
    11
    Hello. Thanks for your reply.
    Both Lightmap Encoding aswell as HDR Cubemap Encoding are already set to High Quality.

    I am now experimenting with the Texture Compression Format to see if I can get a proper hdr texture for the lightbake.
     
  5. LudwigVRtualX

    LudwigVRtualX

    Joined:
    Oct 15, 2018
    Posts:
    11
    I managed to find the right settings.

    I needed to specifically make an override for android in the texture importer settings. The format on android seems to be set to a non hdr format by default even when importing hdr textures.

    The correct setting is: RGB(A) Compressed ASTC HDR 4x4 block. 5x5, 6x6 etc are worse compression quality, but smaller. They all work for hard light and shadow.

    upload_2023-9-8_15-14-51.png

    The Texture Compression Format setting under Project Settings can remain at its default setting (ASTC).

    I would still consider this a bug, as all other build target correctly choose an hdr compression format by default.

    I am also not sure why I cant choose these working compression formats in the "Default" tab of the texture importer. Why do only so few settings appear there?
     

    Attached Files: