/// <summary>
        /// Constructs a new set of GUI elements for inspecting the color grading settings object.
        /// </summary>
        /// <param name="settings">Initial values to assign to the GUI elements.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        public ColorGradingSettingsGUI(ColorGradingSettings settings, GUILayout layout)
        {
            this.settings = settings;

            saturationField.OnChanged   += x => { this.settings.Saturation = x; MarkAsModified(); };
            saturationField.OnFocusLost += ConfirmModify;
            saturationField.OnConfirmed += ConfirmModify;

            contrastField.OnChanged   += x => { this.settings.Contrast = x; MarkAsModified(); };
            contrastField.OnFocusLost += ConfirmModify;
            contrastField.OnConfirmed += ConfirmModify;

            gainField.OnChanged   += x => { this.settings.Gain = x; MarkAsModified(); };
            gainField.OnFocusLost += ConfirmModify;
            gainField.OnConfirmed += ConfirmModify;

            offsetField.OnChanged   += x => { this.settings.Offset = x; MarkAsModified(); };
            offsetField.OnFocusLost += ConfirmModify;
            offsetField.OnConfirmed += ConfirmModify;

            layout.AddElement(saturationField);
            layout.AddElement(contrastField);
            layout.AddElement(gainField);
            layout.AddElement(offsetField);
        }
示例#2
0
        void OnEnable()
        {
            colorGrading = new ColorGradingSettings
            {
                type     = FindProperty(x => x.colorGrading.type),
                exposure = FindProperty(x => x.colorGrading.exposure),

                logLut = FindProperty(x => x.colorGrading.logLut),

                neutralBlackIn    = FindProperty(x => x.colorGrading.neutralBlackIn),
                neutralWhiteIn    = FindProperty(x => x.colorGrading.neutralWhiteIn),
                neutralBlackOut   = FindProperty(x => x.colorGrading.neutralBlackOut),
                neutralWhiteOut   = FindProperty(x => x.colorGrading.neutralWhiteOut),
                neutralWhiteLevel = FindProperty(x => x.colorGrading.neutralWhiteLevel),
                neutralWhiteClip  = FindProperty(x => x.colorGrading.neutralWhiteClip)
            };

            eyeAdaptation = new EyeAdaptationSettings
            {
                enabled = FindProperty(x => x.eyeAdaptation.enabled),
                showDebugHistogramInGameView = FindProperty(x => x.eyeAdaptation.showDebugHistogramInGameView),

                lowPercent  = FindProperty(x => x.eyeAdaptation.lowPercent),
                highPercent = FindProperty(x => x.eyeAdaptation.highPercent),

                minLuminance         = FindProperty(x => x.eyeAdaptation.minLuminance),
                maxLuminance         = FindProperty(x => x.eyeAdaptation.maxLuminance),
                exposureCompensation = FindProperty(x => x.eyeAdaptation.exposureCompensation),

                adaptationType = FindProperty(x => x.eyeAdaptation.adaptationType),

                speedUp   = FindProperty(x => x.eyeAdaptation.speedUp),
                speedDown = FindProperty(x => x.eyeAdaptation.speedDown),

                logMin = FindProperty(x => x.eyeAdaptation.logMin),
                logMax = FindProperty(x => x.eyeAdaptation.logMax)
            };

            chromaSettings = new ChromaticAberrationSettings
            {
                enabled         = FindProperty(x => x.chromaSettings.enabled),
                spectralTexture = FindProperty(x => x.chromaSettings.spectralTexture),
                intensity       = FindProperty(x => x.chromaSettings.intensity)
            };

            vignetteSettings = new VignetteSettings
            {
                enabled    = FindProperty(x => x.vignetteSettings.enabled),
                color      = FindProperty(x => x.vignetteSettings.color),
                center     = FindProperty(x => x.vignetteSettings.center),
                intensity  = FindProperty(x => x.vignetteSettings.intensity),
                smoothness = FindProperty(x => x.vignetteSettings.smoothness)
            };

            globalDithering = FindProperty(x => x.globalDithering);
        }
示例#3
0
        void OnEnable()
        {
            colorGrading = new ColorGradingSettings()
            {
                type     = serializedObject.FindProperty("colorGrading.type"),
                exposure = serializedObject.FindProperty("colorGrading.exposure"),

                logLut = serializedObject.FindProperty("colorGrading.logLut"),

                neutralBlackIn    = serializedObject.FindProperty("colorGrading.neutralBlackIn"),
                neutralWhiteIn    = serializedObject.FindProperty("colorGrading.neutralWhiteIn"),
                neutralBlackOut   = serializedObject.FindProperty("colorGrading.neutralBlackOut"),
                neutralWhiteOut   = serializedObject.FindProperty("colorGrading.neutralWhiteOut"),
                neutralWhiteLevel = serializedObject.FindProperty("colorGrading.neutralWhiteLevel"),
                neutralWhiteClip  = serializedObject.FindProperty("colorGrading.neutralWhiteClip")
            };

            eyeAdaptation = new EyeAdaptationSettings()
            {
                enabled = serializedObject.FindProperty("eyeAdaptation.enabled"),
                showDebugHistogramInGameView = serializedObject.FindProperty("eyeAdaptation.showDebugHistogramInGameView"),

                lowPercent  = serializedObject.FindProperty("eyeAdaptation.lowPercent"),
                highPercent = serializedObject.FindProperty("eyeAdaptation.highPercent"),

                minLuminance         = serializedObject.FindProperty("eyeAdaptation.minLuminance"),
                maxLuminance         = serializedObject.FindProperty("eyeAdaptation.maxLuminance"),
                exposureCompensation = serializedObject.FindProperty("eyeAdaptation.exposureCompensation"),

                adaptationType = serializedObject.FindProperty("eyeAdaptation.adaptationType"),

                speedUp   = serializedObject.FindProperty("eyeAdaptation.speedUp"),
                speedDown = serializedObject.FindProperty("eyeAdaptation.speedDown"),

                logMin = serializedObject.FindProperty("eyeAdaptation.logMin"),
                logMax = serializedObject.FindProperty("eyeAdaptation.logMax")
            };
        }
        internal static bool Prefix(ActiveEnvironment __instance, WeatherStateConfig wsA, WeatherStateConfig wsB, float weatherBlendFrac, TODBlendState todBlendState, float todBlendFrac, float todBlendBiased, bool isIndoors)
        {
            //   if ((Time.frameCount % 50) == 0)
            {
                ColorGradingSettings settings1A = null;
                ColorGradingSettings settings1B = null;
                ColorGradingSettings settings2A = null;
                ColorGradingSettings settings2B = null;

                Traverse       traverseA = Traverse.Create(__instance).Field("m_WorkA");
                TODStateConfig m_WorkA   = traverseA.GetValue <TODStateConfig>();
                Traverse       traverseB = Traverse.Create(__instance).Field("m_WorkB");
                TODStateConfig m_WorkB   = traverseB.GetValue <TODStateConfig>();

                TODStateConfig[] wsA_TodStates = { wsA.m_NightColors, wsA.m_DawnColors, wsA.m_MorningColors, wsA.m_MiddayColors, wsA.m_AfternoonColors, wsA.m_DuskColors, wsA.m_NightColors, wsA.m_NightColors };
                TODStateConfig[] wsB_TodStates = { wsB.m_NightColors, wsB.m_DawnColors, wsB.m_MorningColors, wsB.m_MiddayColors, wsB.m_AfternoonColors, wsB.m_DuskColors, wsB.m_NightColors, wsA.m_NightColors };

                bool flagtoAdd = false;

                int[] nightstates = { 1, 0, 0, 0, 0, 2, 3 };

                float[] keyangles = { Solstice_RV.dawndusk_angle, Solstice_RV.riseset_angle, Solstice_RV.mornaft_angle, Solstice_RV.getSunAngleAtUnitime(Mathf.Floor(Solstice_RV.unitime()) + 0.5f), Solstice_RV.mornaft_angle, Solstice_RV.riseset_angle, Solstice_RV.dawndusk_angle, Solstice_RV.getSunAngleAtUnitime(Mathf.Floor(Solstice_RV.unitime())) };

                if (GameManager.GetUniStorm().m_NormalizedTime > 1f)
                {
                    GameManager.GetUniStorm().SetNormalizedTime(GameManager.GetUniStorm().m_NormalizedTime - 1f);
                    flagtoAdd = true;
                }


                todBlendState = GameManager.GetUniStorm().GetTODBlendState();
                //   Debug.Log(todBlendState);


                int itod = (int)todBlendState;



                string debugtext;

                float zenith = Solstice_RV.getSunAngleAtUnitime(Mathf.Floor(Solstice_RV.unitime()) + 0.5f);
                float nadir  = Solstice_RV.getSunAngleAtUnitime(Mathf.Floor(Solstice_RV.unitime()) + 0.0f);

                float throughpcntzen;
                float throughpcntnad;

                TODStateConfig wsAStartblend;
                TODStateConfig wsAEndblend;
                TODStateConfig wsBStartblend;
                TODStateConfig wsBEndblend;

                TODStateConfig wsAZenblend;
                TODStateConfig wsANadblend;
                TODStateConfig wsBZenblend;
                TODStateConfig wsBNadblend;

                wsAStartblend = wsA_TodStates[itod];
                wsAEndblend   = wsA_TodStates[itod + 1];
                wsBStartblend = wsB_TodStates[itod];
                wsBEndblend   = wsB_TodStates[itod + 1];

                String namestartblend = Enum.GetNames(typeof(TODBlendState))[(int)todBlendState];
                String nameendblend   = Enum.GetNames(typeof(TODBlendState))[((int)todBlendState + 1) % 6];

                float st_ang = keyangles[itod];
                float en_ang = keyangles[itod + 1];

                throughpcntzen = (zenith - st_ang) / (en_ang - st_ang);

                debugtext = Solstice_RV.gggtime(Solstice_RV.unitime()) + " " + Enum.GetNames(typeof(TODBlendState))[(int)todBlendState];

                // do we need a new zen state
                if (throughpcntzen >= 0 && throughpcntzen <= 1)
                {
                    if (itod == (int)TODBlendState.MorningToMidday)// need to correct against game zenith of 45
                    {
                        throughpcntzen = Mathf.Clamp((zenith - st_ang) / (45f - st_ang), 0, 1);
                    }
                    if (itod == (int)TODBlendState.MiddayToAfternoon)// need to correct against game zenith of 45
                    {
                        throughpcntzen = Mathf.Clamp((zenith - 45f) / (en_ang - 45f), 0, 1);
                    }
                    //debugtext += " mc:" + throughpcntzen;
                    wsAZenblend = Solstice_RV.createNewMidPoint(wsA_TodStates[itod], wsA_TodStates[itod + 1], wsA_TodStates[6 - itod], wsA_TodStates[((5 - itod) % 8 + 8) % 8], throughpcntzen);
                    wsBZenblend = Solstice_RV.createNewMidPoint(wsB_TodStates[itod], wsB_TodStates[itod + 1], wsB_TodStates[6 - itod], wsB_TodStates[((5 - itod) % 8 + 8) % 8], throughpcntzen);
                    if (itod < 3)
                    {
                        en_ang       = zenith;
                        nameendblend = "Zen";
                        wsAEndblend  = wsAZenblend;
                        wsBEndblend  = wsBZenblend;
                    }
                    else
                    {
                        st_ang         = zenith;
                        namestartblend = "Zen";
                        wsAStartblend  = wsAZenblend;
                        wsBStartblend  = wsBZenblend;
                    }
                }

                throughpcntnad = (nadir - st_ang) / (en_ang - st_ang);

                if (throughpcntnad >= 0 && throughpcntnad <= 1)
                {
                    debugtext += " mc:" + throughpcntnad + "[" + itod + "][" + (itod + 1) + "][" + (6 - itod) + "][" + ((5 - itod) % 8 + 8) % 8 + "]";

                    wsANadblend = Solstice_RV.createNewMidPoint(wsA_TodStates[itod], wsA_TodStates[itod + 1], wsA_TodStates[6 - itod], wsA_TodStates[((5 - itod) % 8 + 8) % 8], throughpcntnad);
                    wsBNadblend = Solstice_RV.createNewMidPoint(wsB_TodStates[itod], wsB_TodStates[itod + 1], wsB_TodStates[6 - itod], wsB_TodStates[((5 - itod) % 8 + 8) % 8], throughpcntnad);

                    if (itod > 3)
                    {
                        en_ang       = nadir;
                        nameendblend = "Nad";
                        wsAEndblend  = wsANadblend;
                        wsBEndblend  = wsBNadblend;
                    }
                    else
                    {
                        st_ang         = nadir;
                        namestartblend = "Nad";
                        wsAStartblend  = wsANadblend;
                        wsBStartblend  = wsBNadblend;
                    }
                }



                float newtodBlendFrac = (Solstice_RV.getSunAngleAtUnitime(Solstice_RV.unitime()) - st_ang) / (en_ang - st_ang);
                debugtext += "(" + namestartblend + ":" + nameendblend + ")";
                debugtext += " s:" + st_ang + " e:" + en_ang + " c:" + string.Format("{0:0.00}", Solstice_RV.getSunAngleAtUnitime(Solstice_RV.unitime())) + " =:" + string.Format("{0:0.00}", newtodBlendFrac);

                m_WorkA.SetBlended(wsAStartblend, wsAEndblend, newtodBlendFrac, newtodBlendFrac, nightstates[itod]);
                m_WorkB.SetBlended(wsBStartblend, wsBEndblend, newtodBlendFrac, newtodBlendFrac, nightstates[itod]);

                settings1A = wsA_TodStates[(int)todBlendState].m_ColorGradingSettings;
                settings1B = wsA_TodStates[((int)todBlendState + 1) % 7].m_ColorGradingSettings;
                settings2A = wsB_TodStates[(int)todBlendState].m_ColorGradingSettings;
                settings2B = wsB_TodStates[((int)todBlendState + 1) % 7].m_ColorGradingSettings;

                __instance.m_TodState.SetBlended(m_WorkA, m_WorkB, weatherBlendFrac, weatherBlendFrac, 0);

                //if ((Time.frameCount % 1600) == 0) Debug.Log(debugtext);

                if (isIndoors)
                {
                    __instance.m_TodState.SetIndoors();
                }
                else
                {
                    UnityEngine.Rendering.PostProcessing.ColorGrading colorGrading = GameManager.GetCameraEffects().ColorGrading();
                    if (colorGrading != null)
                    {
                        //if ((Time.frameCount % 50) == 0) Debug.Log("[A"+ (int)todBlendState + "][A"+ ((int)todBlendState + 1) % 7 + "[B" + (int)todBlendState + "][B" + ((int)todBlendState + 1) % 7 + "],"+ newtodBlendFrac + ","+ weatherBlendFrac);
                        colorGrading.UpdateLutForTimeOfDay(settings1A, settings1B, settings2A, settings2B, newtodBlendFrac, newtodBlendFrac, weatherBlendFrac);
                        //colorGrading.UpdateLutForTimeOfDay(wsA.m_DawnColors.m_ColorGradingSettings, wsA.m_MorningColors.m_ColorGradingSettings, wsB.m_DawnColors.m_ColorGradingSettings, wsB.m_MorningColors.m_ColorGradingSettings, 0.5f,0.5f, 0.5f);
                    }
                }
                __instance.m_GrassTintScalar = Mathf.Lerp(wsA.m_GrassTintScalar, wsB.m_GrassTintScalar, weatherBlendFrac);

                if (flagtoAdd)
                {
                    GameManager.GetUniStorm().SetNormalizedTime(GameManager.GetUniStorm().m_NormalizedTime + 1f);
                }


                return(false);
            }
        }
示例#5
0
 private static extern void Internal_setcolorGrading(IntPtr thisPtr, ColorGradingSettings value);
 internal static extern void Internal_SetColorGrading(IntPtr obj, ref ColorGradingSettings value);
 internal static extern void Internal_GetColorGrading(IntPtr obj, out ColorGradingSettings resultAsRef);