Search Unity

Question ARFoundation & ARCore HDR light estimation

Discussion in 'AR' started by coder89, Oct 6, 2021.

  1. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
    Hi,

    I'm working on a project where I try to enable HDR light estimation. On a test device I got (some high-end android phone) I run arfoundation-samples app and I realized that mainLightColor and mainLightIntensity properties are reporting strange values (or at least values I did not expect and/or lacking proper documentation). So...

    - mainLightColor - in bright rooms RGB values often get values outside of 0-1 values (i.e. it is not that uncommon to get values above 2.0-3.0 float for each channel). Alpha channel is always set to 1.0.
    - mainLightIntensity - it is always undefined.
    - ambientProbe - can't really tell whether values are correct or not... :)

    So my questions are:
    1. How should I handle mainLightColor properly? I mean how should I set that on my directional light's color property given it's values are outside of expected range (that is outside 0-1 range)? If I pass color value "as-is" objects on the scene render way too bright so that all bright textures turn completely white and black turns grey.
    2. Why there is no mainLightIntensity?

    What am I missing here (and what is missing in the official arfoundation-sample) that would help me to get things working correctly?

    Oh and I am running build-in render pipeline if that makes any difference.

    Thanks in advance!
    /Lukasz
     
  2. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
    Slept just a couple of hours 'cause I couldn't stop thinking about this annoying issue :D

    So... this is what I found in ARCore's SDK repo:
    https://github.com/google-ar/arcore...Scripts/Api/Wrappers/LightEstimateApi.cs#L113

    And here is another one o_O
    https://github.com/google-ar/scenef...com/google/ar/sceneform/ArSceneView.java#L633

    Could someone from Unity team could confirm whether something needs to be done for ARCore devices when HDR light estimation is used along with Build-in render pipeline & standard shaders?

    Also, do I need to use tonemapping from the post-processing stack v2 in order to get the colors right or simple color normalization (link #2) is good enough?
     
    Last edited: Oct 6, 2021
  3. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
    And finally I think I found a more complete explanation of how HDR lightning is supposed to be used in ARCore (not sure if it's the same on ARKit though):
    https://github.com/google-ar/arcore...rc/main/assets/shaders/environmental_hdr.frag

    ALso not completely sure though how to implement that in Unity but my guess it that scale light by "Mathf.Pi" and then normalize would be the way to go. Could someone confirm whether my thinking is correct or not?

    Looks like this fix applied to the samples is no longer valid?
    https://github.com/Unity-Technologi...mmit/a62edf595b039420501cfc1d57b3430c147df530
     
    Last edited: Oct 6, 2021
    KyryloKuzyk likes this.
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    Team had a look and had this guidance to share:

    The energy conservation is already applied within ARFoudnation APIs. Above 1 values are not uncommon in HDR.