Reputation: 121
I have been trying to understand how to use the light estimation
feature of ARCore in my Android app. Most of the tutorials on light estimate is for Unity. However I'm using Android Studio for my project.
If anyone could explain how to use light estimation to trigger a change in shader or an animation upon switching off the lights?
Upvotes: 1
Views: 966
Reputation: 58043
There's no honest Light Estimation in ARCore at the moment, just rough approximation.
Let's see how a code in Android Studio for ARCore's Light Estimation should look like:
try {
session.setCameraTextureName(backgroundRenderer.getTextureId());
Frame frame = session.update();
Camera camera = frame.getCamera();
// Compute lighting from average intensity of the image.
// 3 components here are color factors, the fourth one is intensity.
final float[] colorCorrectionRgba = new float[4];
frame.getLightEstimate().getColorCorrection(colorCorrectionRgba, 0);
} catch (Throwable t) {
Log.e(TAG, "Exception on the OpenGL thread", t);
}
The estimation is simply the average luminosity of the whole captured scene from the color camera of the phone. 1.0
is white and 0.0
is black color. It isn’t related to the actual brightness of the room you’re in, but depends on how the camera is perceiving it through its exposure settings. Camera's exposure is always inaccurate and it depends where camera is pointed to. You get just one global light estimation value for the whole scene. You can’t adjust your object according to the specific regional brightness where your object is placed.
The shader of the Hello_AR_Example
project multiplies the object color with the global light estimate. This adapts (and usually reduces) the RGB brightness of the final surface color.
Upvotes: 3