Пример #1
0
        private void getEffects()
        {
            post_layer = Camera.main.GetComponent <PostProcessLayer>();
            if (post_layer == null)
            {
                Logger.Debug("Null post layer");
            }
            if (post_layer.enabled == false)
            {
                post_layer.enabled = true;
                Logger.Debug("post_layer was disabled");
            }

            // get global volumes, order by decreasing priority
            var allVolumes = FindObjectsOfType <PostProcessVolume>().Where(v => v.isGlobal).OrderBy(v => - v.priority).ToList();

            Logger.Log($"Found {allVolumes.Count} volumes");
            if (allVolumes.Count == 0)
            {
                Logger.Log("No global volumes");
            }
            else if (allVolumes.Count == 1)
            {
                Logger.Log("Only 1 global volume");
                map_post_volume = post_volume = allVolumes.First();
            }
            else if (allVolumes.Count == 2)                 // expected behaviour
            {
                Logger.Log("Exactly 2 global volumes");
                post_volume     = allVolumes[0];
                map_post_volume = allVolumes[1];
            }
            else
            {
                Logger.Log("More than 2 global volumes");
                post_volume     = allVolumes[0];
                map_post_volume = allVolumes[1];
            }

            // get effects for the mod
            effectSuite = EffectSuite.FromVolume(post_volume);

            // get global map volume effects
            map_effectSuite = EffectSuite.FromVolume(map_post_volume);


            FXAA = post_layer.fastApproximateAntialiasing;
            TAA  = post_layer.temporalAntialiasing;
            SMAA = post_layer.subpixelMorphologicalAntialiasing;

            mapPreset.GetMapEffects();

            // enable volumetric lighting/fog/...
            var pipelineAsset = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;

            pipelineAsset.renderPipelineSettings.supportVolumetrics = true;

            presetsManager.ApplySettings();
            presetsManager.ApplyPresets();

            // After applying, can now save
            Main.canSave = true;

            //cameraController.GetHeadMaterials();
            //DayNightController.Instance.GetLights();

            Logger.Debug("Done getEffects");
        }
Пример #2
0
        public static EffectSuite FromVolume(PostProcessVolume post_volume)
        {
            if (post_volume == null)
            {
                Logger.Debug("Post_volume is null in EffectSuite.FromVolume");
                return(null);
            }

            var    suite     = new EffectSuite();
            string not_found = "";

            if ((suite.AO = post_volume.profile.GetSetting <AmbientOcclusion>()) == null)
            {
                not_found += "ao,";
                suite.AO   = post_volume.profile.AddSettings <AmbientOcclusion>();
                suite.AO.enabled.Override(false);
            }
            if ((suite.EXPO = post_volume.profile.GetSetting <AutoExposure>()) == null)
            {
                not_found += "expo,";
                suite.EXPO = post_volume.profile.AddSettings <AutoExposure>();
                suite.EXPO.enabled.Override(false);
            }
            if ((suite.BLOOM = post_volume.profile.GetSetting <Bloom>()) == null)
            {
                not_found  += "bloom,";
                suite.BLOOM = post_volume.profile.AddSettings <Bloom>();
                suite.BLOOM.enabled.Override(false);
            }
            if ((suite.CA = post_volume.profile.GetSetting <ChromaticAberration>()) == null)
            {
                not_found += "ca,";
                suite.CA   = post_volume.profile.AddSettings <ChromaticAberration>();
                suite.CA.enabled.Override(false);
            }
            if ((suite.COLOR = post_volume.profile.GetSetting <ColorGrading>()) == null)
            {
                not_found  += "color,";
                suite.COLOR = post_volume.profile.AddSettings <ColorGrading>();
                suite.COLOR.enabled.Override(false);
            }
            if ((suite.DOF = post_volume.profile.GetSetting <DepthOfField>()) == null)
            {
                not_found += "dof,";
                suite.DOF  = post_volume.profile.AddSettings <DepthOfField>();
                suite.DOF.enabled.Override(false);
            }
            if ((suite.GRAIN = post_volume.profile.GetSetting <Grain>()) == null)
            {
                not_found  += "grain,";
                suite.GRAIN = post_volume.profile.AddSettings <Grain>();
                suite.GRAIN.enabled.Override(false);
            }
            if ((suite.BLUR = post_volume.profile.GetSetting <MotionBlur>()) == null)
            {
                not_found += "blur,";
                suite.BLUR = post_volume.profile.AddSettings <MotionBlur>();
                suite.BLUR.enabled.Override(false);
            }
            if ((suite.LENS = post_volume.profile.GetSetting <LensDistortion>()) == null)
            {
                not_found += "lens,";
                suite.LENS = post_volume.profile.AddSettings <LensDistortion>();
                suite.LENS.enabled.Override(false);
            }
            if ((suite.REFL = post_volume.profile.GetSetting <ScreenSpaceReflections>()) == null)
            {
                not_found += "refl,";
                suite.REFL = post_volume.profile.AddSettings <ScreenSpaceReflections>();
                suite.REFL.enabled.Override(false);
            }
            if ((suite.VIGN = post_volume.profile.GetSetting <Vignette>()) == null)
            {
                not_found += "vign,";
                suite.VIGN = post_volume.profile.AddSettings <Vignette>();
                suite.VIGN.enabled.Override(false);
            }

            if (not_found.Length > 0)
            {
                Logger.Debug("Not found: " + not_found);
            }

            return(suite);
        }