示例#1
0
    protected void LerpEyeAdapt(float rate)
    {
        float EYE_ACTIVATION_LIMIT = 0.05f;

        transitionProfile.eyeAdaptation.enabled = EnableOrDisableEffect(oldProfile.eyeAdaptation.enabled, futureProfile.eyeAdaptation.enabled, rate, EYE_ACTIVATION_LIMIT);

        EyeAdaptationModel.Settings currentSettings = oldProfile.eyeAdaptation.settings;
        EyeAdaptationModel.Settings futureSettings  = futureProfile.eyeAdaptation.settings;

        // Luminosity Range

        currentSettings.logMin = (int)Mathf.Lerp(currentSettings.logMin, futureSettings.logMin, rate);
        currentSettings.logMax = (int)Mathf.Lerp(currentSettings.logMax, futureSettings.logMax, rate);

        // Auto Exposure

        currentSettings.lowPercent   = Mathf.Lerp(currentSettings.lowPercent, futureSettings.lowPercent, rate);
        currentSettings.highPercent  = Mathf.Lerp(currentSettings.highPercent, futureSettings.highPercent, rate);
        currentSettings.minLuminance = Mathf.Lerp(currentSettings.minLuminance, futureSettings.minLuminance, rate);
        currentSettings.maxLuminance = Mathf.Lerp(currentSettings.maxLuminance, futureSettings.maxLuminance, rate);
//		Lerp(currentSettings.dynamicKeyValue)

        // Adaptation
//		Lerp(currentSettings.adaptationType)
        currentSettings.speedUp   = Mathf.Lerp(currentSettings.speedUp, futureSettings.speedUp, rate);
        currentSettings.speedDown = Mathf.Lerp(currentSettings.speedDown, futureSettings.speedDown, rate);

        transitionProfile.eyeAdaptation.settings = currentSettings;
    }
    private static void ConvertEyeAdaptionSettings(PostProcessProfile ppp, EyeAdaptationModel.Settings eye)
    {
        var eye2 = ppp.AddSettings <AutoExposure>();

        eye2.eyeAdaptation.overrideState = true;
        eye2.eyeAdaptation.value         = eye.adaptationType == EyeAdaptationModel.EyeAdaptationType.Fixed
            ? EyeAdaptation.Fixed
            : EyeAdaptation.Progressive;

        eye2.keyValue.overrideState = true;
        eye2.keyValue.value         = eye.keyValue;
        // Not supported: eye.dynamicKeyValue;
        //                eye.highPercent;
        //                eye.logMax;
        //                eye.logMin;
        //                eye.lowPercent;
        eye2.maxLuminance.overrideState = true;
        eye2.maxLuminance.value         = eye.maxLuminance;
        eye2.minLuminance.overrideState = true;
        eye2.minLuminance.value         = eye.minLuminance;
        eye2.speedDown.overrideState    = true;
        eye2.speedDown.value            = eye.speedDown;
        eye2.speedUp.overrideState      = true;
        eye2.speedUp.value = eye.speedUp;
    }
        void Start()
        {
            // Replace the profile with its clone.
            var postfx = GetComponent <PostProcessingBehaviour>();

            _profile       = Instantiate <PostProcessingProfile>(postfx.profile);
            postfx.profile = _profile;

            // Initialize the public structs with the current profile.
            enableAntialiasing = _profile.antialiasing.enabled;
            antialiasing       = _profile.antialiasing.settings;

            enableAmbientOcclusion = _profile.ambientOcclusion.enabled;
            ambientOcclusion       = _profile.ambientOcclusion.settings;

            enableScreenSpaceReflection = _profile.screenSpaceReflection.enabled;
            screenSpaceReflection       = _profile.screenSpaceReflection.settings;

            enableDepthOfField = _profile.depthOfField.enabled;
            depthOfField       = _profile.depthOfField.settings;

            enableMotionBlur = _profile.motionBlur.enabled;
            motionBlur       = _profile.motionBlur.settings;

            enableEyeAdaptation = _profile.eyeAdaptation.enabled;
            eyeAdaptation       = _profile.eyeAdaptation.settings;

            enableBloom = _profile.bloom.enabled;
            bloom       = _profile.bloom.settings;

            enableColorGrading = _profile.colorGrading.enabled;
            colorGrading       = _profile.colorGrading.settings;

            enableUserLut = _profile.userLut.enabled;
            userLut       = _profile.userLut.settings;

            enableChromaticAberration = _profile.chromaticAberration.enabled;
            chromaticAberration       = _profile.chromaticAberration.settings;

            enableGrain = _profile.grain.enabled;
            grain       = _profile.grain.settings;

            enableVignette = _profile.vignette.enabled;
            vignette       = _profile.vignette.settings;
        }
示例#4
0
        private static void WriteEA(List <string> lines, EyeAdaptationModel.Settings settings)
        {
            lines.Append("Eye_Adaptation", 1);
            lines.Append("{", 1);

            lines.Append("Luminosity_Minimum = " + settings.logMin, 2);
            lines.Append("Luminosity_Maximum = " + settings.logMax, 2);
            lines.Append("Maximum_EV = " + settings.maxLuminance, 2);
            lines.Append("Minimum_EV = " + settings.minLuminance, 2);
            lines.Append("Dynamic_Key_Value = " + settings.dynamicKeyValue.Convert(), 2);
            lines.Append("Type = " + (int)settings.adaptationType, 2);
            lines.Append("Speed_Up = " + settings.speedUp, 2);
            lines.Append("Speed_Down = " + settings.speedDown, 2);
            lines.Append("Range = " + settings.lowPercent + ", " + settings.highPercent, 2);
            lines.Append("Key_Value = " + settings.keyValue, 2);

            lines.Append("}", 1);
        }
        //public void Reset()
        //{
        //    OnEnable();
        //}
        internal void SetProfile(PostProcessingProfile __profile)
        {
            enableAntialiasing = __profile.antialiasing.enabled;
            antialiasing       = __profile.antialiasing.settings;

            enableAmbientOcclusion = __profile.ambientOcclusion.enabled;
            ambientOcclusion       = __profile.ambientOcclusion.settings;

            enableScreenSpaceReflection = __profile.screenSpaceReflection.enabled;
            screenSpaceReflection       = __profile.screenSpaceReflection.settings;

            enableDepthOfField = __profile.depthOfField.enabled;
            depthOfField       = __profile.depthOfField.settings;

            enableMotionBlur = __profile.motionBlur.enabled;
            motionBlur       = __profile.motionBlur.settings;

            enableEyeAdaptation = __profile.eyeAdaptation.enabled;
            eyeAdaptation       = __profile.eyeAdaptation.settings;

            enableBloom = __profile.bloom.enabled;
            bloom       = __profile.bloom.settings;

            enableColorGrading = __profile.colorGrading.enabled;
            colorGrading       = __profile.colorGrading.settings;

            enableUserLut = __profile.userLut.enabled;
            userLut       = __profile.userLut.settings;

            enableChromaticAberration = __profile.chromaticAberration.enabled;
            chromaticAberration       = __profile.chromaticAberration.settings;

            enableGrain = __profile.grain.enabled;
            grain       = __profile.grain.settings;

            enableVignette = __profile.vignette.enabled;
            vignette       = __profile.vignette.settings;

            enableDither = __profile.dithering.enabled;

            enableFog = __profile.fog.enabled;
            fog       = __profile.fog.settings;
        }
示例#6
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;
                 * }
                 */
            }