Example #1
0
        void OnEnable()
        {
            m_CommandBuffers       = new Dictionary <Type, KeyValuePair <CameraEvent, CommandBuffer> >();
            m_MaterialFactory      = new MaterialFactory();
            m_RenderTextureFactory = new RenderTextureFactory();
            m_Context = new PostProcessingContext();

            // Keep a list of all post-fx for automation purposes
            m_Components = new List <PostProcessingComponentBase>();

            // Component list
            m_DebugViews            = AddComponent(new BuiltinDebugViewsComponent());
            m_AmbientOcclusion      = AddComponent(new AmbientOcclusionComponent());
            m_ScreenSpaceReflection = AddComponent(new ScreenSpaceReflectionComponent());
            m_FogComponent          = AddComponent(new FogComponent());
            m_MotionBlur            = AddComponent(new MotionBlurComponent());
            m_Taa                 = AddComponent(new TaaComponent());
            m_EyeAdaptation       = AddComponent(new EyeAdaptationComponent());
            m_DepthOfField        = AddComponent(new DepthOfFieldComponent());
            m_Bloom               = AddComponent(new BloomComponent());
            m_ChromaticAberration = AddComponent(new ChromaticAberrationComponent());
            m_ColorGrading        = AddComponent(new ColorGradingComponent());
            m_UserLut             = AddComponent(new UserLutComponent());
            m_Grain               = AddComponent(new GrainComponent());
            m_Vignette            = AddComponent(new VignetteComponent());
            m_Dithering           = AddComponent(new DitheringComponent());
            m_Fxaa                = AddComponent(new FxaaComponent());

            // Prepare state observers
            m_ComponentStates = new Dictionary <PostProcessingComponentBase, bool>();

            foreach (var component in m_Components)
            {
                m_ComponentStates.Add(component, false);
            }

            useGUILayout = false;
        }
Example #2
0
        static void PostfixPostProcessingOnEnable(PostProcessingBehaviour __instance, TaaComponent ___m_Taa, Dictionary <PostProcessingComponentBase, bool> ___m_ComponentStates, List <PostProcessingComponentBase> ___m_Components)
        {
            if (VHVRConfig.NonVrPlayer())
            {
                return;
            }
            ___m_ComponentStates.Remove(___m_Taa);
            ___m_Components.Remove(___m_Taa);

            var vrTaaComponent = new VRTaaComponent();

            VRTaaComponent.PostProcessingExtension.Add(__instance, vrTaaComponent);

            ___m_Components.Add(vrTaaComponent);
            ___m_ComponentStates.Add(vrTaaComponent, false);
        }
Example #3
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;
                 * }
                 */
            }