LightEstimate

public class LightEstimate

Holds information about the estimated lighting of the real scene. Returned by Frame.getLightEstimate()

Nested Classes

enum
Light Estimate States. 

Public Methods

Image[]
acquireEnvironmentalHdrCubeMap ()
Gets the 6 cubemap textures in OpenGL texture format based on the inferred Environmental HDR lighting.
void
getColorCorrection (float[] outColorCorrection4, int offset)
Returns RGB scaling factors to be applied to the final color computed in the fragment shader.
float[]
getEnvironmentalHdrAmbientSphericalHarmonics ()
Gets the spherical harmonics coefficients for the ambient illumination based on the inferred Environmental HDR lighting.
float[]
getEnvironmentalHdrMainLightDirection ()
Returns the direction of the main directional light based on the inferred Environmental HDR light estimation.
float[]
getEnvironmentalHdrMainLightIntensity ()
Returns the intensity of the main directional light based on the inferred Environmental HDR lighting estimation.
float
getPixelIntensity ()
Returns the pixel intensity of the current camera view in gamma color space.
LightEstimate.State
getState ()
Returns the validity of this lighting estimate.
long
getTimestamp ()
Returns the timestamp of the LightEstimate in nanoseconds.

Inherited Methods

Public Methods

acquireEnvironmentalHdrCubeMap

 public 
  
  Image 
 [] 
 
  
 acquireEnvironmentalHdrCubeMap 
 () 

Gets the 6 cubemap textures in OpenGL texture format based on the inferred Environmental HDR lighting.

Details
Returns
An array that contains 6 images in AIMAGE_FORMAT_RGBA_FP16 format for the HDR cubemap. The memory layout for the image data is identical to GL_RGBA16F . The pixel values are in linear color space. The order of the images corresponds to the cubemap order in the following fashion:
  • cubemap[0] : GL_TEXTURE_CUBE_MAP_POSITIVE_X
  • cubemap[1] : GL_TEXTURE_CUBE_MAP_NEGATIVE_X
  • cubemap[2] : GL_TEXTURE_CUBE_MAP_POSITIVE_Y
  • cubemap[3] : GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
  • cubemap[4] : GL_TEXTURE_CUBE_MAP_POSITIVE_Z
  • cubemap[5] : GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
If Config.LightEstimationMode.ENVIRONMENTAL_HDR mode is not set, all textures will be assigned with zero pixel values. All 6 acquired images must be released with Image.close() once they are no longer needed.

getColorCorrection

 public 
  
 void 
  
 getColorCorrection 
 ( 
  
 float 
 [] 
  
 outColorCorrection4 
 , 
  
 int 
  
 offset 
 ) 

Returns RGB scaling factors to be applied to the final color computed in the fragment shader. The last component contains the average pixel intensity. The color correction method uses the green channel as reference baseline and scales the red and blue channels accordingly. In this way the overall intensity will not be significantly changed. If Config.LightEstimationMode.AMBIENT_INTENSITY mode is not set, returns all zeros.

The RGB scale factors can be used independently from the pixel intensity value. They are put together for the convenience of only having to upload one float4 to the fragment shader.

The RGB scale factors are not intended to brighten nor dim the scene. They are only to shift the color of the virtual object towards the color of the light; not intensity of the light. The pixel intensity is used to match the intensity of the light in the scene.

Color correction values are reported in gamma color space. If rendering in gamma color space, multiply them component-wise against the final calculated color after rendering. If rendering in linear space, first convert the values to linear space by rising to the power 2.2.

Details
Parameters
outColorCorrection4
The float array the 4 component color correction values are written to. The four values are:
  • outColorCorrection4[0] : Color correction value for the red channel. This value is larger or equal to zero.
  • outColorCorrection4[1] : Color correction value for the green channel. This value is always 1.0 as the green channel is the reference baseline.
  • outColorCorrection4[2] : Color correction value for the blue channel. This value is larger or equal to zero.
  • outColorCorrection4[3] : This value is identical to the average pixel intensity from getPixelIntensity() in the range [0.0, 1.0] .
offset
The offset into the array the 4 color correction components are written.

getEnvironmentalHdrAmbientSphericalHarmonics

 public 
  
 float 
 [] 
  
 getEnvironmentalHdrAmbientSphericalHarmonics 
 () 

Gets the spherical harmonics coefficients for the ambient illumination based on the inferred Environmental HDR lighting.

Details
Returns The output spherical harmonics coefficients for the ambient illumination. This array contains 9 sets of per-channel coefficients, or a total of 27 values of 32-bit floating point type. The coefficients are stored in a channel-major fashion e.g. [r0, g0, b0, r1, g1, b1, ... , r8, g8, b8] . If Config.LightEstimationMode.ENVIRONMENTAL_HDR mode is not set, returns zero for all 27 coefficients.

getEnvironmentalHdrMainLightDirection

 public 
  
 float 
 [] 
  
 getEnvironmentalHdrMainLightDirection 
 () 

Returns the direction of the main directional light based on the inferred Environmental HDR light estimation. If Config.LightEstimationMode.ENVIRONMENTAL_HDR mode is not set, returns [0.0, 1.0, 0.0] , representing a light shining straight down from above.

Details
Returns The normalized output lighting direction of the main directional light as 3 floats [x, y, z] .

getEnvironmentalHdrMainLightIntensity

 public 
  
 float 
 [] 
  
 getEnvironmentalHdrMainLightIntensity 
 () 

Returns the intensity of the main directional light based on the inferred Environmental HDR lighting estimation. All return values are larger or equal to zero. If Config.LightEstimationMode.ENVIRONMENTAL_HDR mode is not set, returns zero for all elements of the array.

Details
Returns The output lighting intensity of the main directional light as 3 floats [r, g, b].

getPixelIntensity

 public 
  
 float 
  
 getPixelIntensity 
 () 

Returns the pixel intensity of the current camera view in gamma color space. Values are in the range [0.0, 1.0] , with zero being black and one being white. If Config.LightEstimationMode.AMBIENT_INTENSITY mode is not set, returns zero.

If rendering in gamma color space, divide this value by 0.466, which is middle gray in gamma color space, and multiply against the final calculated color after rendering. If rendering in linear space, first convert this value to linear space by rising to the power 2.2. Normalize the result by dividing it by 0.18, which is middle gray in linear space. Then multiply by the final calculated color after rendering.

getState

 public 
  
  LightEstimate 
 . 
 State 
 
  
 getState 
 () 

Returns the validity of this lighting estimate. When the estimate is LightEstimate.State.NOT_VALID it should not be used for rendering.

getTimestamp

 public 
  
 long 
  
 getTimestamp 
 () 

Returns the timestamp of the LightEstimate in nanoseconds.

ARCore returns a different timestamp when the underlying light estimate has changed. Conversely, the same timestamp is returned if the light estimate has not changed.

This timestamp uses the same time base as Frame.getTimestamp() .

Design a Mobile Site
View Site in Mobile | Classic
Share by: