Search Unity

ARFoundation - Enabling Light Estimation

Discussion in 'AR' started by Dalbino, Jan 31, 2019.

Thread Status:
Not open for further replies.
  1. Dalbino

    Dalbino

    Joined:
    Dec 20, 2013
    Posts:
    5
    According to the ARFoundation manual (https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@1.0/manual/index.html) you are supposed to enable Light Estimation in the AR Session component if you want access to that information. However, this option is not visible to me.

    When I try the Light Estimation sample scene (provided here: https://github.com/Unity-Technologies/arfoundation-samples) the app does not work.

    I am running Unity 2018.3.3f1 and AR Foundation 1.0.0-preview.22.

    I have added some visuals:
    ar-light-estimation-problem.png
     
  2. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    They've changed things recently. You now have to manually add the "AR Camera Options" script to the AR Camera
    In there you'll find some settings
     
    bowserscastle likes this.
  3. Dalbino

    Dalbino

    Joined:
    Dec 20, 2013
    Posts:
    5
    The sample project image above uses the scene 'LightEstimation', in which the AR Camera already uses the script "AR Camera Options" with the Light Estimation option enabled. So that doesn't seem to be the problem.
     
  4. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    The docs are indeed out of date; we've updated them for the next release.

    So you're saying even with this option checked, light estimation doesn't work?
     
  5. Dalbino

    Dalbino

    Joined:
    Dec 20, 2013
    Posts:
    5
    It appears so. In the light estimation scene from the sample projects it is checked, but when I run it I get the image shown in the original post, i.e. no values, only the text "new text". (Also no virtual object appears either, in case that is supposed to happen?)
     
  6. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    That's a mistake in the sample; light estimation was working, but the text fields were not updated. Should be fixed now.
     
    Dalbino likes this.
  7. Dalbino

    Dalbino

    Joined:
    Dec 20, 2013
    Posts:
    5
    Thank you very much for the fix! Then it seems light estimation works as intended (my bad for not testing it more thoroughly myself).
    Brightness and Color Correct are now updating and showing values. Color Temp is oddly enough only showing Unavailable though.
     
  8. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    Color temp is only available on ARKit. ARCore only surfaces color correction.
     
    Dalbino likes this.
  9. Dalbino

    Dalbino

    Joined:
    Dec 20, 2013
    Posts:
    5
    That explains it! Thanks td!
     
  10. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Just checked that color correction, the result is horrible. In a good room light conditions brightness value range is 0.40-0.50 what is a reason of AR objects become too dark. I had to multiply that result 5x times to makes something more realistic..
    Can somebody explain me, why that happens?
     
  11. jipsen

    jipsen

    Joined:
    May 22, 2018
    Posts:
    37
    I don't think I understand light estimation too much. I'm not sure what values to put into color correction to make it visibly change. My object stays the same darkness no matter what value I put in color correction or what kind of light is in the room. There is a definite difference in color between using the light estimation and not using it though, so I know something is working. Can any help?
     
  12. Sk8ape

    Sk8ape

    Joined:
    Mar 23, 2014
    Posts:
    3
    Same here, after doing the implementation of the light estimation script, my 3D object is way too dark. I've been following this Unity video


    Does anyone have any idea why this is?
     
  13. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Did you bake the lightning on a scene?
     
  14. Sk8ape

    Sk8ape

    Joined:
    Mar 23, 2014
    Posts:
    3
    I have not, at least not knowingly.
     
  15. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Check it, that was the issue in my case months ago
     
  16. Sk8ape

    Sk8ape

    Joined:
    Mar 23, 2014
    Posts:
    3
    I rebuilt the scene starting with the Unity base Light estimation scene, and now I can see my object just fine, but the light estimation itself doesn't seem to work properly as far as figuring light intensity and direction. the script is applied to the light but it doesn't seem to be rotating or changing intensity.
     
  17. BardurM

    BardurM

    Joined:
    Mar 24, 2015
    Posts:
    1
    I have the same problem. Light estimation has very little effect (on Android at least) and the directional light doesn't change intensity or direction. I've added the light estimation script from ARfoundation samples.
    I can't really figure out what the issue could be or if this is just a bug.

    It worked flawlessly with ARCore. But ARfoundation just shows the object exactly how it looks in unity. static light and no change in color/temp/brightness.
     
    dnnkeeper likes this.
  18. proprodark102

    proprodark102

    Joined:
    Feb 8, 2019
    Posts:
    1
    Hey, I just wonder if this is fixed. I tried light estimation but it has no effect at all. Even I put my hand over my camera to make the light intensity become zero, the object is unchanged and the color is still the same.
     
    Jasr_88 likes this.
  19. Jasr_88

    Jasr_88

    Joined:
    Mar 21, 2016
    Posts:
    9
    Hello, Debugging the "args" variable I can see the following output of the light estimation :

    lightEstimation: (Avg. Brightness: 0.5368686, Avg. Color Temperature: , Color Correction: RGBA(1.013, 1.000, 0.953, 0.537), Avg. Intensity in Lumens: 1073.737)

    Even if I focus my camera directly to the sun the "Avg. Brightness" value is never greater than 0.6, and the Color Correction values are too high for a RGBA form 0 to 1 and too low for a RGBA from 0 to 255.

    i'm very confused since my app was working fine a few months ago, but now even the sample scene gives me this outputs in android and iOS.

    i'm using ARFoundation 2.1.4 (From Package Manager) in unity 2019.1.14f1 i'll appreciate any information
     
    grubertm_unity likes this.
  20. Jasr_88

    Jasr_88

    Joined:
    Mar 21, 2016
    Posts:
    9
    so... no news about this issue?
     
  21. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Ditto... also, never point your phone camera directly at the sun...
     
  22. mranger

    mranger

    Joined:
    Jan 26, 2019
    Posts:
    13
    Same. HDR lighting detection and usage seems to be a unicorn.
     
    Jasr_88 likes this.
  23. richard_revesz

    richard_revesz

    Joined:
    Feb 1, 2018
    Posts:
    6
    Hi, any update on this? :)
     
  24. Jasr_88

    Jasr_88

    Joined:
    Mar 21, 2016
    Posts:
    9
    Well turns out that they modified this feature to include some others values like Light Direction and sphericalHarmonics now in ARFoundation Version 3.1.0 (preview4) the LightEstimation object have the following properties:

    LightEstimation.brightness
    LightEstimation.colorTemperature
    LightEstimation.colorCorrection
    LightEstimation.mainLightDirection
    LightEstimation.mainLightColor
    LightEstimation.mainLightIntensityLumens
    LightEstimation.sphericalHarmonics

    As you can see, this is much more infromation than the given in the former versión (2.2.0 for example):
    Avg. Brightness
    Avg. Color Temperature
    Color Correction
    Avg. IntensityInLumens

    So if you where using a script similar to the showed in this tutorial
    now instead of use colorTemperature or colorCorrection values for your main ligth, we need to use LightEstimation.mainLightColor and LightEstimation.mainLightDirection to achieve the desired effect

    The problem is not thecnical or a bug is just the lack of documentation

    Now days the example on https://github.com/Unity-Technologies/arfoundation-samples is working with this features, so now we have to hope that the code remains working the same way, or if its modified wait 3 monts for a working example on the official repo.
     
  25. paul-lens

    paul-lens

    Joined:
    Jun 17, 2019
    Posts:
    1
    I can't get the sample for light estimation to work.
    Im on Unity 2020.1.0b5. AR Foundation, AR Subsystems, AR Core all on 4.0.0-preview.1

    When i try run the sample on my OPPO Reno Z, all the values read unavailable. This phone is listed as supported in the AR Core device list. Running Android 9 and newest version of Google Play Services for AR. Is there something ive missed in setup?
     
  26. jipsen

    jipsen

    Joined:
    May 22, 2018
    Posts:
    37
    All too often it could be the simple fact it is broken in the newer versions of Unity. I'm not saying this is always the issue but pretty often I find it is. Try running it in an earlier version 2019.3.xx and see if it works or not.
     
    Rs likes this.
  27. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    So how should these values be used exactly? When looking at HDRLightEstimation.cs from the samples, they do

    Code (CSharp):
    1. m_Light.color = mainLightColor.Value;
    but also

    Code (CSharp):
    1. m_Light.color = colorCorrection.Value;
    So which one do I use?
     
    Emericanized and SolidAlloy like this.
Thread Status:
Not open for further replies.