public LightEstimate GetLightEstimate() { IntPtr lightEstimateHandle = m_NativeSession.LightEstimateApi.Create(); ExternApi.ArFrame_getLightEstimate( m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, lightEstimateHandle); LightEstimateState state = m_NativeSession.LightEstimateApi.GetState(lightEstimateHandle); Color colorCorrection = m_NativeSession.LightEstimateApi.GetColorCorrection(lightEstimateHandle); long timestamp = m_NativeSession.LightEstimateApi.GetTimestamp( m_NativeSession.SessionHandle, lightEstimateHandle); Quaternion mainLightRotation = Quaternion.identity; Color mainLightColor = Color.black; // TODO: remove if condition when b/132436697 is fixed. if (state == LightEstimateState.Valid) { m_NativeSession.LightEstimateApi.GetMainDirectionalLight( m_NativeSession.SessionHandle, lightEstimateHandle, out mainLightRotation, out mainLightColor); m_NativeSession.LightEstimateApi.GetAmbientSH(m_NativeSession.SessionHandle, lightEstimateHandle, m_AmbientSH); } m_NativeSession.LightEstimateApi.Destroy(lightEstimateHandle); return(new LightEstimate(state, colorCorrection.a, new Color(colorCorrection.r, colorCorrection.g, colorCorrection.b, 1f), mainLightRotation, mainLightColor, m_AmbientSH, timestamp)); }
/// <summary> /// Constructor for a LightEstimate. /// </summary> /// <param name="state">State of the estimate.</param> /// <param name="pixelIntensity">Average pixel intensity. Values range from 0.0 /// to 1.0, where 0.0 represents black and 1.0 represents white.</param> /// <param name="colorCorrection">Color correction RGB scaling factors to be /// applied to the final color computed by the fragment shader to match the /// ambient color.</param> public LightEstimate( LightEstimateState state, float pixelIntensity, Color colorCorrection) : this() { State = state; PixelIntensity = pixelIntensity; ColorCorrection = colorCorrection; }
public LightEstimate GetLightEstimate() { IntPtr lightEstimateHandle = _nativeSession.LightEstimateApi.Create(); ExternApi.ArFrame_getLightEstimate( _nativeSession.SessionHandle, _nativeSession.FrameHandle, lightEstimateHandle); LightEstimateState state = _nativeSession.LightEstimateApi.GetState(lightEstimateHandle); Color colorCorrection = _nativeSession.LightEstimateApi.GetColorCorrection(lightEstimateHandle); long timestamp = _nativeSession.LightEstimateApi.GetTimestamp( _nativeSession.SessionHandle, lightEstimateHandle); Quaternion mainLightRotation = Quaternion.identity; Color mainLightColor = Color.black; _nativeSession.LightEstimateApi.GetMainDirectionalLight( _nativeSession.SessionHandle, lightEstimateHandle, out mainLightRotation, out mainLightColor); _nativeSession.LightEstimateApi.GetAmbientSH(_nativeSession.SessionHandle, lightEstimateHandle, _ambientSH); _nativeSession.LightEstimateApi.Destroy(lightEstimateHandle); return(new LightEstimate(state, colorCorrection.a, new Color(colorCorrection.r, colorCorrection.g, colorCorrection.b, 1f), mainLightRotation, mainLightColor, _ambientSH, timestamp)); }
public LightEstimate GetLightEstimate() { IntPtr lightEstimateHandle = m_NativeSession.LightEstimateApi.Create(); ExternApi.ArFrame_getLightEstimate(m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, lightEstimateHandle); LightEstimateState state = m_NativeSession.LightEstimateApi.GetState(lightEstimateHandle); Color colorCorrection = m_NativeSession.LightEstimateApi.GetColorCorrection(lightEstimateHandle); m_NativeSession.LightEstimateApi.Destroy(lightEstimateHandle); return(new LightEstimate(state, colorCorrection.a, new Color(colorCorrection.r, colorCorrection.g, colorCorrection.b, 1f))); }
public LightEstimate GetLightEstimate(IntPtr frameHandle) { IntPtr lightEstimateHandle = m_NativeApi.LightEstimate.Create(); ExternApi.ArFrame_getLightEstimate(m_NativeApi.SessionHandle, frameHandle, lightEstimateHandle); LightEstimateState state = m_NativeApi.LightEstimate.GetState(lightEstimateHandle); float pixelIntensity = m_NativeApi.LightEstimate.GetPixelIntensity(lightEstimateHandle); m_NativeApi.LightEstimate.Destroy(lightEstimateHandle); return(new LightEstimate(state, pixelIntensity)); }
public LightEstimate GetLightEstimate(IntPtr frameHandle) { IntPtr lightEstimateHandle = m_NativeSession.LightEstimateApi.Create(); ExternApi.arFrameGetLightEstimate(m_NativeSession.SessionHandle, frameHandle, lightEstimateHandle); LightEstimateState state = m_NativeSession.LightEstimateApi.GetState(lightEstimateHandle); float pixelIntensity = m_NativeSession.LightEstimateApi.GetPixelIntensity(lightEstimateHandle); Color colorCorrection = m_NativeSession.LightEstimateApi.GetColorCorrection(lightEstimateHandle); m_NativeSession.LightEstimateApi.Destroy(lightEstimateHandle); return(new LightEstimate(state, pixelIntensity, colorCorrection)); }
public Cubemap GetReflectionCubemap() { IntPtr lightEstimateHandle = m_NativeSession.LightEstimateApi.Create(); ExternApi.ArFrame_getLightEstimate( m_NativeSession.SessionHandle, m_NativeSession.FrameHandle, lightEstimateHandle); LightEstimateState state = m_NativeSession.LightEstimateApi.GetState(lightEstimateHandle); if (state != LightEstimateState.Valid) { return(null); } Cubemap cubemap = m_NativeSession.LightEstimateApi.GetReflectionCubemap( m_NativeSession.SessionHandle, lightEstimateHandle); m_NativeSession.LightEstimateApi.Destroy(lightEstimateHandle); return(cubemap); }
/// <summary> /// Constructor for a LightEstimate. /// </summary> /// <param name="state">State of the estimate.</param> /// <param name="pixelIntensity">Average pixel intensity. Values range from 0.0 /// to 1.0, where 0.0 represents black and 1.0 represents white.</param> /// <param name="colorCorrection">Color correction RGB scaling factors to be /// applied to the final color computed by the fragment shader to match the /// ambient color. 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. /// </param> /// <param name="directionalLightRotation">The rotation of the main directional light /// estimated by ARCore.</param> /// <param name="directionalLightColor">The color of the main directional light estimated /// by ARCore.</param> /// <param name="ambientSHCoefficients">A 2D float[3, 9] array that store the spherical /// harmonics coefficients estimated by ARCore. </param> /// <param name="timestamp">The timestamp of the LightEstimate.</param> public LightEstimate( LightEstimateState state, float pixelIntensity, Color colorCorrection, Quaternion directionalLightRotation, Color directionalLightColor, float[,] ambientSHCoefficients, long timestamp) : this() { _InitializeLightEstimateMode(); State = state; Timestamp = timestamp; m_PixelIntensity = pixelIntensity; m_ColorCorrection = colorCorrection; m_DirectionalLightRotation = directionalLightRotation; // Apply the energy conservation term to the light color directly since Unity doesn't // apply the term in their standard shader. m_DirectionalLightColor = directionalLightColor; // Apply gamma correction to the light color. Unity light color is in gamma space. m_DirectionalLightColor = m_DirectionalLightColor.gamma; // Unity spherical harmonics is in linear space. var ambientProbe = new SphericalHarmonicsL2(); if (ambientSHCoefficients != null) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { ambientProbe[i, j] = ambientSHCoefficients[j, i]; } } } m_AmbientProbe = ambientProbe; m_CachedCubemap = null; }
public LightEstimate( LightEstimateState state, float pixelIntensity, Color colorCorrection) : this(state, pixelIntensity, colorCorrection, Quaternion.identity, Color.black, null, -1) { }
/// <summary> /// Constructor for a LightEstimate. /// </summary> /// <param name="state">State of the estimate.</param> /// <param name="pixelIntensity">Average pixel intensity. Values range from 0.0 /// to 1.0, where 0.0 represents black and 1.0 represents white.</param> public LightEstimate(LightEstimateState state, float pixelIntensity) { State = state; PixelIntensity = pixelIntensity; }