Esempio n. 1
0
        // This code is re-used from HDAdditionalLightData
        float ConvertLightIntensitySpotAngleLumenToUnit(float value)
        {
            var spotLightShape = m_Light.spotLightShape.GetEnumValue <SpotLightShape>();
            var spotAngle      = m_Light.settings.spotAngle.floatValue;
            var aspectRatio    = m_Light.aspectRatio.floatValue;

            // If reflector is enabled all the lighting from the sphere is focus inside the solid angle of current shape
            if (spotLightShape == SpotLightShape.Cone)
            {
                value = LightUtils.ConvertSpotLightLumenToCandela(value, spotAngle * Mathf.Deg2Rad, true);
            }
            else if (spotLightShape == SpotLightShape.Pyramid)
            {
                float angleA, angleB;
                LightUtils.CalculateAnglesForPyramid(aspectRatio, spotAngle * Mathf.Deg2Rad, out angleA, out angleB);

                value = LightUtils.ConvertFrustrumLightLumenToCandela(value, angleA, angleB);
            }
            else // Box shape, fallback to punctual light.
            {
                value = LightUtils.ConvertPointLightLumenToCandela(value);
            }

            // Units so far are in Candela now, last step is to get it in terms of the actual unit.
            return(HDLightUI.ConvertLightIntensity(LightUnit.Candela, m_Unit, m_Light, m_Editor, value));
        }
Esempio n. 2
0
        float UnitToLumen(float value)
        {
            if (m_Unit == LightUnit.Lumen)
            {
                return(value);
            }

            return(HDLightUI.ConvertLightIntensity(m_Unit, LightUnit.Lumen, m_Light, m_Editor, value));
        }
Esempio n. 3
0
        float UnitToLumen(float value)
        {
            if (m_Unit == LightUnit.Lumen)
            {
                return(value);
            }

            // Punctual slider currently does not have any regard for spot shape/reflector.
            // Conversions need to happen as if light is a point, and this is the only setting that influences that.
            m_Light.enableSpotReflector.boolValue = false;

            return(HDLightUI.ConvertLightIntensity(m_Unit, LightUnit.Lumen, m_Light, m_Editor, value));
        }
Esempio n. 4
0
        float LumenToUnit(float value)
        {
            if (m_Unit == LightUnit.Lumen)
            {
                return(value);
            }

            // Once again temporarily disable reflector in case we called this for tooltip or context menu preset.
            m_Light.enableSpotReflector.boolValue = false;

            value = HDLightUI.ConvertLightIntensity(LightUnit.Lumen, m_Unit, m_Light, m_Editor, value);

            // Restore the state of spot reflector on the light.
            m_Light.enableSpotReflector.boolValue = m_SpotReflectorEnabled;

            return(value);
        }
Esempio n. 5
0
        float LumenToUnit(float value)
        {
            if (m_Unit == LightUnit.Lumen)
            {
                return(value);
            }

            if (m_Light.type == HDLightType.Spot &&
                m_Unit != LightUnit.Lumen &&
                m_Light.enableSpotReflector.boolValue)
            {
                // Note: When reflector is flagged, the util conversion for Lumen -> Candela will actually force re-use
                // the serialized intensity, which is not what we want in this case. Because of this, we re-use the formulation
                // in HDAdditionalLightData to correctly compute the intensity for spot reflector.
                return(ConvertLightIntensitySpotAngleLumenToUnit(value));
            }

            return(HDLightUI.ConvertLightIntensity(LightUnit.Lumen, m_Unit, m_Light, m_Editor, value));
        }