LightEstimate

public class LightEstimate

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

Nested Classes

enum LightEstimate.State Light Estimate States. 

Protected Constructors

LightEstimate()
(FOR TESTING) Constructs a new instance for use as a mock.

Public Methods

ArImage[]
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

Protected Constructors

protected LightEstimate ()

(FOR TESTING) Constructs a new instance for use as a mock. Calling any base method implementation on this instance may return unexpected results, throw an exception, or even crash.

To obtain a LightEstimate normally, use getLightEstimate().

Public Methods

public ArImage[] acquireEnvironmentalHdrCubeMap ()

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

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 ENVIRONMENTAL_HDR mode is not set, all textures will be assigned with zero pixel values. All 6 acquired images must be released with close() once they are no longer needed.

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 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.

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.

public float[] getEnvironmentalHdrAmbientSphericalHarmonics ()

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

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 ENVIRONMENTAL_HDR mode is not set, returns zero for all 27 coefficients.

public float[] getEnvironmentalHdrMainLightDirection ()

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

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

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 ENVIRONMENTAL_HDR mode is not set, returns zero for all elements of the array.

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

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 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.

public LightEstimate.State getState ()

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

public long getTimestamp ()

Returns the timestamp of the LightEstimate in nanoseconds. This timestamp uses the same time base as getTimestamp().

Send feedback about...