Search Unity

Question Possible to capture mainLightRotation values in ARFoundation from rear camera?

Discussion in 'AR' started by xeye, May 26, 2021.

  1. xeye

    xeye

    Joined:
    Jun 25, 2013
    Posts:
    37
    I am having an issue catching mainLightRotation values in ARFoundation. Anybody know if this is only able to be captured via user-facing camera sensor, or is it possible to grab it from the rear camera as well? (Not using ARCore, btw - this is iOS only!)
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,144
  3. eugeneloza

    eugeneloza

    Joined:
    Dec 3, 2019
    Posts:
    24
    iOS doesn't provide you with mainLightDirection (at least not through AR Foundation 4.1.7 and below) - as in "none of the devices we were testing with reported this value".
     
    KyryloKuzyk likes this.
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Note from the team: mainLightDirection is only supported in front-facing camera mode on iOS.
     
    eugeneloza likes this.
  5. DreamPower

    DreamPower

    Joined:
    Apr 2, 2017
    Posts:
    103
    I just implemented this as a hack. I turn on all the light estimation features and use the front camera with a throwaway face effect to get the light direction. Then when the user taps the screen, it switches to only requesting AmbientIntensity, disables LightEstimation on the light, and requests the rear (world-facing) camera. Wait a frame or two and turn the LightEstimation back on so the light can get AmbientIntensity, and now the light is pointing roughly the same direction the room light (of course it won't change if the room lighting changes).

    Note, it's not guaranteed Apple would allow this in the app store, they don't like you having face tracking enabled if you aren't actually using it.