Exemple #1
0
 private void SetValues()
 {
     basicSettings     = pp.profile.colorGrading.settings.basic;
     temperatureTarget = basicSettings.temperature;
     temperatureSpeed  = 1;
     hueTarget         = basicSettings.hueShift;
     hueSpeed          = 1;
 }
    protected void LerpColorGrading(float rate)
    {
        float CG_ACTIVATION_LIMIT = 0.05f;

        transitionProfile.colorGrading.enabled = EnableOrDisableEffect(oldProfile.colorGrading.enabled, futureProfile.colorGrading.enabled, rate, CG_ACTIVATION_LIMIT);

        ColorGradingModel.Settings settings = oldProfile.colorGrading.settings;

        ColorGradingModel.TonemappingSettings currentTone  = settings.tonemapping;
        ColorGradingModel.TonemappingSettings futureTone   = futureProfile.colorGrading.settings.tonemapping;
        ColorGradingModel.BasicSettings       currentBasic = settings.basic;
        ColorGradingModel.BasicSettings       futureBasic  = futureProfile.colorGrading.settings.basic;
        ColorGradingModel.ColorWheelsSettings currentWheel = settings.colorWheels;
        ColorGradingModel.ColorWheelsSettings futureWheel  = futureProfile.colorGrading.settings.colorWheels;

        // TONEMAPPING

        currentTone.neutralBlackIn    = Mathf.Lerp(currentTone.neutralBlackIn, futureTone.neutralBlackIn, rate);
        currentTone.neutralWhiteIn    = Mathf.Lerp(currentTone.neutralWhiteIn, futureTone.neutralWhiteIn, rate);
        currentTone.neutralBlackOut   = Mathf.Lerp(currentTone.neutralBlackOut, futureTone.neutralBlackOut, rate);
        currentTone.neutralWhiteOut   = Mathf.Lerp(currentTone.neutralWhiteOut, futureTone.neutralWhiteOut, rate);
        currentTone.neutralWhiteLevel = Mathf.Lerp(currentTone.neutralWhiteLevel, futureTone.neutralWhiteLevel, rate);
        currentTone.neutralWhiteClip  = Mathf.Lerp(currentTone.neutralWhiteClip, futureTone.neutralWhiteClip, rate);

        // BASIC

        currentBasic.postExposure = Mathf.Lerp(currentBasic.postExposure, futureBasic.postExposure, rate);
        currentBasic.temperature  = Mathf.Lerp(currentBasic.temperature, futureBasic.temperature, rate);
        currentBasic.tint         = Mathf.Lerp(currentBasic.tint, futureBasic.tint, rate);
        currentBasic.hueShift     = Mathf.Lerp(currentBasic.hueShift, futureBasic.hueShift, rate);
        currentBasic.saturation   = Mathf.Lerp(currentBasic.saturation, futureBasic.saturation, rate);
        currentBasic.contrast     = Mathf.Lerp(currentBasic.contrast, futureBasic.contrast, rate);

        // COLOR WHEELS

        currentWheel.log.slope    = Color.Lerp(currentWheel.log.slope, futureWheel.log.slope, rate);
        currentWheel.log.power    = Color.Lerp(currentWheel.log.power, futureWheel.log.power, rate);
        currentWheel.log.offset   = Color.Lerp(currentWheel.log.offset, futureWheel.log.offset, rate);
        currentWheel.linear.lift  = Color.Lerp(currentWheel.linear.lift, futureWheel.linear.lift, rate);
        currentWheel.linear.gamma = Color.Lerp(currentWheel.linear.gamma, futureWheel.linear.gamma, rate);
        currentWheel.linear.gain  = Color.Lerp(currentWheel.linear.gain, futureWheel.linear.gain, rate);

        settings.tonemapping = currentTone;
        settings.basic       = currentBasic;
        settings.colorWheels = currentWheel;

        transitionProfile.colorGrading.settings = settings;
    }
Exemple #3
0
    internal void RefreshDeprivationUX(SurvivalTimer survivalTimer)
    {
        bool isPowerDeprived  = survivalTimer.Data.Power.DeprivationSeconds > 0f,
             isOxygenDeprived = survivalTimer.Data.Oxygen.DeprivationSeconds > 0f,
             isFoodDeprived   = survivalTimer.Data.Food.DeprivationSeconds > 0f,
             isWaterDeprived  = survivalTimer.Data.Water.DeprivationSeconds > 0f;

        ShowingDeprivationUX = isPowerDeprived || isOxygenDeprived || isFoodDeprived || isWaterDeprived;

        //sounds
        if (isOxygenDeprived && !PlayerInput.Instance.HeartbeatSource.isPlaying)
        {
            PlayerInput.Instance.VocalSource.clip = PlayerInput.Instance.HeartbeatsAndVocals.Gasping;
            PlayerInput.Instance.VocalSource.Play();
            PlayerInput.Instance.HeartbeatSource.clip = PlayerInput.Instance.HeartbeatsAndVocals.SlowToDeathHeartbeat;
            PlayerInput.Instance.HeartbeatSource.Play();
        }
        else if (isPowerDeprived && !PlayerInput.Instance.HeartbeatSource.isPlaying)
        {
            PlayerInput.Instance.VocalSource.clip = PlayerInput.Instance.HeartbeatsAndVocals.Chattering;
            PlayerInput.Instance.VocalSource.Play();
            PlayerInput.Instance.HeartbeatSource.clip = PlayerInput.Instance.HeartbeatsAndVocals.SlowHeartbeat;
            PlayerInput.Instance.HeartbeatSource.Play();
        }
        else if (isFoodDeprived && !PlayerInput.Instance.HeartbeatSource.isPlaying)
        {
            PlayerInput.Instance.HeartbeatSource.clip = PlayerInput.Instance.HeartbeatsAndVocals.SlowHeartbeat;
            PlayerInput.Instance.HeartbeatSource.Play();
        }
        else if (isWaterDeprived && !PlayerInput.Instance.HeartbeatSource.isPlaying)
        {
            PlayerInput.Instance.HeartbeatSource.clip = PlayerInput.Instance.HeartbeatsAndVocals.SlowHeartbeat;
            PlayerInput.Instance.HeartbeatSource.Play();
        }
        else if (!ShowingDeprivationUX && PlayerInput.Instance.HeartbeatSource.isPlaying)
        {
            PlayerInput.Instance.HeartbeatSource.Stop();
            PlayerInput.Instance.VocalSource.Stop();
        }

        //colorgrading
        if (isOxygenDeprived)
        {
            PostProfile.colorGrading.enabled = true;
            float lerpT = survivalTimer.Data.Oxygen.DeprivationSeconds / survivalTimer.DeprivationDurations.OxygenDeprivationSurvivalTimeSeconds;
            ColorGradingModel.Settings      newSettings = ColorGradingModel.Settings.defaultSettings;
            ColorGradingModel.BasicSettings newBasics   = ColorGradingModel.BasicSettings.defaultSettings;
            newBasics.saturation = Mathf.Min(1f, Mathf.Lerp(1f, 0f, lerpT) + .25f);
            newBasics.contrast   = Mathf.Lerp(1f, 2f, lerpT);
            newSettings.basic    = newBasics;
            PostProfile.colorGrading.settings = newSettings;
        }
        else if (isPowerDeprived)
        {
            PostProfile.colorGrading.enabled = true;
            float lerpT = survivalTimer.Data.Power.DeprivationSeconds / survivalTimer.DeprivationDurations.PowerDeprivationSurvivalTimeSeconds;
            ColorGradingModel.Settings      newSettings = ColorGradingModel.Settings.defaultSettings;
            ColorGradingModel.BasicSettings newBasics   = ColorGradingModel.BasicSettings.defaultSettings;
            newBasics.temperature             = Mathf.Lerp(0f, -40f, lerpT);
            newSettings.basic                 = newBasics;
            PostProfile.colorGrading.settings = newSettings;
        }
        else if (isWaterDeprived)
        {
            PostProfile.colorGrading.enabled = true;
            float lerpT = survivalTimer.Data.Water.DeprivationSeconds / survivalTimer.DeprivationDurations.WaterDeprivationSurvivalTimeSeconds;
            ColorGradingModel.Settings      newSettings = ColorGradingModel.Settings.defaultSettings;
            ColorGradingModel.BasicSettings newBasics   = ColorGradingModel.BasicSettings.defaultSettings;
            newBasics.temperature             = Mathf.Lerp(0f, 35f, lerpT);
            newBasics.saturation              = Mathf.Lerp(1f, 0f, lerpT);
            newSettings.basic                 = newBasics;
            PostProfile.colorGrading.settings = newSettings;
        }
        else if (isFoodDeprived)
        {
            PostProfile.colorGrading.enabled = true;
            float lerpT = survivalTimer.Data.Food.DeprivationSeconds / survivalTimer.DeprivationDurations.FoodDeprivationSurvivalTimeSeconds;
            ColorGradingModel.Settings      newSettings = ColorGradingModel.Settings.defaultSettings;
            ColorGradingModel.BasicSettings newBasics   = ColorGradingModel.BasicSettings.defaultSettings;
            newBasics.contrast   = Mathf.Lerp(1f, 1.5f, lerpT);
            newBasics.saturation = Mathf.Lerp(1f, 0f, lerpT);
            newSettings.basic    = newBasics;
            PostProfile.colorGrading.settings = newSettings;
        }
        else
        {
            PostProfile.colorGrading.enabled = false;
        }

        //motion blur
        if (isFoodDeprived)
        {
            PostProfile.motionBlur.enabled = true;
            float lerpT = survivalTimer.Data.Food.DeprivationSeconds / survivalTimer.DeprivationDurations.FoodDeprivationSurvivalTimeSeconds;
            MotionBlurModel.Settings newSettings = MotionBlurModel.Settings.defaultSettings;
            newSettings.frameBlending       = Mathf.Lerp(1f, 0.5f, lerpT);
            newSettings.shutterAngle        = Mathf.Lerp(0f, 360f, lerpT);
            newSettings.sampleCount         = 4;
            PostProfile.motionBlur.settings = newSettings;
        }

        //depth of field
        if (isWaterDeprived)
        {
            PostProfile.depthOfField.enabled = true;
            float lerpT = survivalTimer.Data.Water.DeprivationSeconds / survivalTimer.DeprivationDurations.WaterDeprivationSurvivalTimeSeconds;
            DepthOfFieldModel.Settings newSettings = DepthOfFieldModel.Settings.defaultSettings;
            //DepthOfFieldModel.BasicSettings newBasics = DepthOfFieldModel.BasicSettings.defaultSettings;
            newSettings.aperture              = Mathf.Lerp(5f, 0.05f, lerpT);
            newSettings.useCameraFov          = true;
            newSettings.focusDistance         = 1f;
            newSettings.kernelSize            = DepthOfFieldModel.KernelSize.VeryLarge;
            PostProfile.depthOfField.settings = newSettings;
        }

        //vignetting
        if (isOxygenDeprived)
        {
            PostProfile.vignette.enabled = true;
            float lerpT = survivalTimer.Data.Oxygen.DeprivationSeconds;
            lerpT -= (float)Math.Truncate(lerpT);

            VignetteModel.Settings newSettings = VignetteModel.Settings.defaultSettings;
            newSettings.color             = new Color(51f / 255f, 51f / 255f, 51f / 255f);
            newSettings.intensity         = Mathf.PingPong(lerpT, .5f);
            newSettings.smoothness        = 1f;
            newSettings.roundness         = 1f;
            PostProfile.vignette.settings = newSettings;
        }
        else if (isPowerDeprived)
        {
            PostProfile.vignette.enabled = true;
            float lerpT = survivalTimer.Data.Power.DeprivationSeconds / survivalTimer.DeprivationDurations.PowerDeprivationSurvivalTimeSeconds;

            VignetteModel.Settings newSettings = VignetteModel.Settings.defaultSettings;
            newSettings.color             = new Color(68f / 255f, 108f / 255f, 255f / 255f);
            newSettings.intensity         = Mathf.Lerp(0f, 0.76f, lerpT);
            newSettings.smoothness        = 0.169f;
            newSettings.roundness         = 1;
            PostProfile.vignette.settings = newSettings;
        }
        else if (isFoodDeprived)
        {
            PostProfile.vignette.enabled = true;
            float lerpT = survivalTimer.Data.Food.DeprivationSeconds / survivalTimer.DeprivationDurations.FoodDeprivationSurvivalTimeSeconds;

            VignetteModel.Settings newSettings = VignetteModel.Settings.defaultSettings;
            newSettings.color             = new Color(32f / 255f, 32f / 255f, 32f / 255f);
            newSettings.intensity         = Mathf.Lerp(0f, 0.4f, lerpT);
            newSettings.smoothness        = Mathf.Lerp(0f, 0.5f, lerpT);
            newSettings.roundness         = 1;
            PostProfile.vignette.settings = newSettings;
        }
        else
        {
            PostProfile.vignette.enabled = false;
        }
    }
Exemple #4
0
            static void Postfix(ref VignetteComponent ___m_Vignette, ref BloomComponent ___m_Bloom, ref EyeAdaptationComponent ___m_EyeAdaptation, ref DepthOfFieldComponent ___m_DepthOfField, ref MotionBlurComponent ___m_MotionBlur, ref ColorGradingComponent ___m_ColorGrading, ref TaaComponent ___m_Taa, ref FxaaComponent ___m_Fxaa, ref AmbientOcclusionComponent ___m_AmbientOcclusion)
            {
                if (enabled && settings.customVignette)
                {
                    VignetteModel.Settings vSettings = new VignetteModel.Settings
                    {
                        mode       = VignetteModel.Mode.Classic,
                        intensity  = settings.vignetteIntensity,
                        color      = new Color(settings.vignetteColorRed, settings.vignetteColorGreen, settings.vignetteColorBlue, settings.vignetteColorAlpha),
                        center     = new Vector2(settings.vignetteX, settings.vignetteY),
                        smoothness = settings.vignetteSmoothness,
                        roundness  = settings.vignetteRoundness,
                        rounded    = settings.vignetteRounded
                    };
                    ___m_Vignette.model.settings = vSettings;
                }
                else
                {
                    ___m_Vignette.model.settings = defaultVignetteSettings;
                }

                if (enabled && settings.customBloom)
                {
                    BloomModel.BloomSettings bbSettings = new BloomModel.BloomSettings
                    {
                        intensity   = settings.bloomIntensity,
                        threshold   = settings.bloomThreshold,
                        softKnee    = settings.bloomSoftKnee,
                        radius      = settings.bloomRadius,
                        antiFlicker = settings.bloomAntiFlicker
                    };

                    BloomModel.LensDirtSettings blSettings = new BloomModel.LensDirtSettings
                    {
                        texture   = ___m_Bloom.model.settings.lensDirt.texture,
                        intensity = settings.bloomLensDirtIntensity
                    };
                    BloomModel.Settings bSettings = new BloomModel.Settings
                    {
                        bloom    = bbSettings,
                        lensDirt = blSettings
                    };

                    ___m_Bloom.model.settings = bSettings;
                }
                else
                {
                    ___m_Bloom.model.settings = defaultBloomSettings;
                }

                if (enabled && settings.customEyeAdapt)
                {
                    EyeAdaptationModel.Settings eSettings = new EyeAdaptationModel.Settings
                    {
                        lowPercent      = settings.eyeAdaptLowPercent,
                        highPercent     = settings.eyeAdaptHighPercent,
                        minLuminance    = settings.eyeAdaptMinLuminance,
                        maxLuminance    = settings.eyeAdaptMaxLuminance,
                        keyValue        = settings.eyeAdaptKeyValue,
                        dynamicKeyValue = settings.eyeAdaptDynamicKeyValue,
                        adaptationType  = settings.eyeAdaptAdaptationFixed?EyeAdaptationModel.EyeAdaptationType.Fixed: EyeAdaptationModel.EyeAdaptationType.Progressive,
                        speedUp         = settings.eyeAdaptSpeedUp,
                        speedDown       = settings.eyeAdaptSpeedDown,
                        logMin          = settings.eyeAdaptLogMin,
                        logMax          = settings.eyeAdaptLogMax,
                    };

                    ___m_EyeAdaptation.model.settings = eSettings;
                }
                else
                {
                    ___m_EyeAdaptation.model.settings = defaultEyeAdaptSettings;
                }

                if (enabled && settings.customMotionBlur)
                {
                    MotionBlurModel.Settings mSettings = new MotionBlurModel.Settings
                    {
                        shutterAngle  = settings.motionBlurShutterAngle,
                        sampleCount   = settings.motionBlurSampleCount,
                        frameBlending = settings.motionBlurFrameBlending
                    };

                    ___m_MotionBlur.model.settings = mSettings;
                }
                else
                {
                    ___m_MotionBlur.model.settings = defaultMotionBlurSettings;
                }

                if (enabled && settings.customDepthOfField)
                {
                    DepthOfFieldModel.Settings dSettings = new DepthOfFieldModel.Settings
                    {
                        focusDistance = settings.depthOfFieldFocusDistance,
                        aperture      = settings.depthOfFieldAperture,
                        focalLength   = settings.depthOfFieldFocalLength,
                        useCameraFov  = settings.depthOfFieldUseCameraFov,
                        kernelSize    = (DepthOfFieldModel.KernelSize)settings.depthOfFieldKernelSize,
                    };

                    ___m_DepthOfField.model.settings = dSettings;
                    ___m_DepthOfField.model.enabled  = true;
                }
                else
                {
                    ___m_DepthOfField.model.settings = defaultDepthOfFieldSettings;
                    ___m_DepthOfField.model.enabled  = false;
                }

                if (enabled && settings.customColorGrading)
                {
                    ColorGradingModel.TonemappingSettings ctSettings = new ColorGradingModel.TonemappingSettings
                    {
                        tonemapper        = (ColorGradingModel.Tonemapper)settings.colorGradingTonemapper,
                        neutralBlackIn    = settings.colorGradingNeutralBlackIn,
                        neutralWhiteIn    = settings.colorGradingNeutralWhiteIn,
                        neutralBlackOut   = settings.colorGradingNeutralBlackOut,
                        neutralWhiteOut   = settings.colorGradingNeutralWhiteOut,
                        neutralWhiteLevel = settings.colorGradingNeutralWhiteLevel,
                        neutralWhiteClip  = settings.colorGradingNeutralWhiteClip
                    };

                    ColorGradingModel.BasicSettings cbSettings = new ColorGradingModel.BasicSettings
                    {
                        postExposure = settings.colorGradingPostExposure,
                        temperature  = settings.colorGradingTemperature,
                        tint         = settings.colorGradingTint,
                        hueShift     = settings.colorGradingHueShift,
                        saturation   = settings.colorGradingSaturation,
                        contrast     = settings.colorGradingContrast
                    };

                    ColorGradingModel.Settings cSettings = new ColorGradingModel.Settings
                    {
                        tonemapping  = ctSettings,
                        basic        = cbSettings,
                        channelMixer = ___m_ColorGrading.model.settings.channelMixer,
                        colorWheels  = ___m_ColorGrading.model.settings.colorWheels,
                        curves       = ___m_ColorGrading.model.settings.curves
                    };

                    ___m_ColorGrading.model.settings = cSettings;
                }
                else
                {
                    ___m_ColorGrading.model.settings = defaultColorGradingSettings;
                }

                if (enabled && settings.customAO)
                {
                    AmbientOcclusionModel.Settings aSettings = new AmbientOcclusionModel.Settings
                    {
                        intensity    = settings.AOIntensity,
                        radius       = settings.AORadius,
                        sampleCount  = (AmbientOcclusionModel.SampleCount)sampleCounts.Values.ToArray()[settings.AOSampleCount],
                        downsampling = settings.AODownsampling,
                        forceForwardCompatibility = settings.AOForceForwardCompatibility,
                        ambientOnly   = settings.AOAmbientOnly,
                        highPrecision = settings.AOHighPrecision
                    };

                    ___m_AmbientOcclusion.model.settings = aSettings;
                }
                else
                {
                    ___m_AmbientOcclusion.model.settings = defaultAOSettings;
                }

                /*
                 *
                 * if(!defaultAASet)
                 * {
                 *  defaultAATaaSettings = ___m_Taa.model.settings;
                 *  defaultAAFxaaSettings = ___m_Fxaa.model.settings;
                 *  defaultAASet = true;
                 * }
                 *
                 * if (enabled && settings.customAA)
                 * {
                 *  AntialiasingModel.FxaaSettings afSettings = new AntialiasingModel.FxaaSettings
                 *  {
                 *      preset = (AntialiasingModel.FxaaPreset) settings.AAFxaaPreset
                 *  };
                 *
                 *  AntialiasingModel.TaaSettings atSettings = new AntialiasingModel.TaaSettings
                 *  {
                 *      jitterSpread = settings.AAJitterSpread,
                 *      sharpen = settings.AASharpen,
                 *      stationaryBlending = settings.AAStationaryBlending,
                 *      motionBlending = settings.AAMotionBlending
                 *
                 *  };
                 *
                 *  AntialiasingModel.Settings aSettings = new AntialiasingModel.Settings
                 *  {
                 *      //method = settings.AAMethodTaa?AntialiasingModel.Method.Taa: AntialiasingModel.Method.Fxaa,
                 *      method = ___m_Taa.model.settings.method,
                 *      fxaaSettings = afSettings,
                 *      taaSettings = atSettings
                 *  };
                 *
                 *  AntialiasingModel.Settings aSettings2 = new AntialiasingModel.Settings
                 *  {
                 *      //method = settings.AAMethodTaa?AntialiasingModel.Method.Taa: AntialiasingModel.Method.Fxaa,
                 *      method = ___m_Fxaa.model.settings.method,
                 *      fxaaSettings = afSettings,
                 *      taaSettings = atSettings
                 *  };
                 *
                 *  ___m_Taa.model.settings = aSettings;
                 *  ___m_Fxaa.model.settings = aSettings2;
                 * }
                 * else
                 * {
                 *  ___m_Taa.model.settings = defaultAATaaSettings;
                 *  ___m_Fxaa.model.settings = defaultAAFxaaSettings;
                 * }
                 */
            }