Esempio n. 1
0
    void OnCameraFrameReceived(ARCameraFrameEventArgs camFrameEvent)
    {
        LightEstimationData led = camFrameEvent.lightEstimation;

        if (led.averageBrightness.HasValue)
        {
            lightComponent.intensity = led.averageBrightness.Value;
        }

        if (led.averageColorTemperature.HasValue)
        {
            lightComponent.colorTemperature = led.averageColorTemperature.Value;
        }
    }
Esempio n. 2
0
    protected virtual void UpdateLight(LightEstimationData lightEstimation)
    {
        if (topLight != null)
        {
            if (lightEstimation.averageBrightness.HasValue)
            {
                // brightness multiplied for more visible effects
                var brightness = lightEstimation.averageBrightness.Value * 2f;

                // set brightness on directional light
                topLight.intensity = brightness;
            }

            if (lightEstimation.colorCorrection.HasValue)
            {
                // get color correction value ( we use it as base )
                var colorCorrection = lightEstimation.colorCorrection.Value;

                // ligh tcolor change based on colorCorrection -> does not give good results -> we keep the light white
                //topLight.color = new Color(colorCorrection.r, colorCorrection.g, colorCorrection.b) * topLight.intensity;

                // get sprite renderer
                SpriteRenderer spriteRenderer = imageInRoom.GetComponent <SpriteRenderer>();

                // WE SET THE SPRITE SHADER COLOR instead of the light color ( allows for more dramatic changes when lights are really low brightness )
                // calculate sprite color overlay based on colorColoraction and light intensity
                var spriteColor = new Color(colorCorrection.r, colorCorrection.g, colorCorrection.b) * topLight.intensity;
                spriteRenderer.material.color = new Color(spriteColor.r, spriteColor.g, spriteColor.b, 1.0f);
            }

            if (lightEstimation.averageColorTemperature.HasValue)
            {
                // set color colorTemperature on image TODO figure out if this can also be used on the sprite renderer color
                topLight.colorTemperature = lightEstimation.averageColorTemperature.Value;
            }
        }
    }