Ejemplo n.º 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");
        }
Ejemplo n.º 2
0
        private void getSettings()
        {
            post_layer = Camera.main.GetComponent <PostProcessLayer>();
            if (post_layer == null)
            {
                if (Main.settings.DEBUG)
                {
                    log("Null post layer");
                }
            }
            if (post_layer.enabled == false)
            {
                post_layer.enabled = true;
                if (Main.settings.DEBUG)
                {
                    log("post_layer was disabled");
                }
            }
            post_volume = FindObjectOfType <PostProcessVolume>();
            if (post_volume != null)
            {
                string not_found = "";
                if ((GAME_AO = post_volume.profile.GetSetting <AmbientOcclusion>()) == null)
                {
                    not_found += "ao,";
                    GAME_AO    = post_volume.profile.AddSettings <AmbientOcclusion>();
                    GAME_AO.enabled.Override(false);
                }
                if ((GAME_EXPO = post_volume.profile.GetSetting <AutoExposure>()) == null)
                {
                    not_found += "expo,";
                    GAME_EXPO  = post_volume.profile.AddSettings <AutoExposure>();
                    GAME_EXPO.enabled.Override(false);
                }
                if ((GAME_BLOOM = post_volume.profile.GetSetting <Bloom>()) == null)
                {
                    not_found += "bloom,";
                    GAME_BLOOM = post_volume.profile.AddSettings <Bloom>();
                    GAME_BLOOM.enabled.Override(false);
                }
                if ((GAME_CA = post_volume.profile.GetSetting <ChromaticAberration>()) == null)
                {
                    not_found += "ca,";
                    GAME_CA    = post_volume.profile.AddSettings <ChromaticAberration>();
                    GAME_CA.enabled.Override(false);
                }
                if ((GAME_COLOR = post_volume.profile.GetSetting <ColorGrading>()) == null)
                {
                    not_found += "color,";
                    GAME_COLOR = post_volume.profile.AddSettings <ColorGrading>();
                    GAME_COLOR.enabled.Override(false);
                }
                if ((GAME_DOF = post_volume.profile.GetSetting <DepthOfField>()) == null)
                {
                    not_found += "dof,";
                    GAME_DOF   = post_volume.profile.AddSettings <DepthOfField>();
                    GAME_DOF.enabled.Override(false);
                }
                if ((GAME_GRAIN = post_volume.profile.GetSetting <Grain>()) == null)
                {
                    not_found += "grain,";
                    GAME_GRAIN = post_volume.profile.AddSettings <Grain>();
                    GAME_GRAIN.enabled.Override(false);
                }
                if ((GAME_BLUR = post_volume.profile.GetSetting <MotionBlur>()) == null)
                {
                    not_found += "blur,";
                    GAME_BLUR  = post_volume.profile.AddSettings <MotionBlur>();
                    GAME_BLUR.enabled.Override(false);
                }
                if ((GAME_LENS = post_volume.profile.GetSetting <LensDistortion>()) == null)
                {
                    not_found += "lens,";
                    GAME_LENS  = post_volume.profile.AddSettings <LensDistortion>();
                    GAME_LENS.enabled.Override(false);
                }
                if ((GAME_REFL = post_volume.profile.GetSetting <ScreenSpaceReflections>()) == null)
                {
                    not_found += "refl,";
                    GAME_REFL  = post_volume.profile.AddSettings <ScreenSpaceReflections>();
                    GAME_REFL.enabled.Override(false);
                }
                if ((GAME_VIGN = post_volume.profile.GetSetting <Vignette>()) == null)
                {
                    not_found += "vign,";
                    GAME_VIGN  = post_volume.profile.AddSettings <Vignette>();
                    GAME_VIGN.enabled.Override(false);
                }
                if (not_found.Length > 0)
                {
                    log("Not found: " + not_found);
                }
            }
            else
            {
                if (Main.settings.DEBUG)
                {
                    log("Post_volume is null in getSettings");
                }
            }

            GAME_FXAA = post_layer.fastApproximateAntialiasing;
            GAME_TAA  = post_layer.temporalAntialiasing;
            GAME_SMAA = post_layer.subpixelMorphologicalAntialiasing;

            bool map_preset_enabled = false;

            if (Main.presets.ContainsKey(Main.map_name))
            {
                map_preset_enabled = Main.presets[Main.map_name].enabled;
            }
            map_preset         = new Preset(Main.map_name);
            map_preset.enabled = map_preset_enabled;
            UpdateMapPreset(map_preset);
            Main.presets[map_preset.name] = map_preset;
            if (!Main.settings.presetOrder.Contains(Main.map_name))
            {
                Main.settings.presetOrder.Add(Main.map_name);
            }

            if (Main.settings.DEBUG)
            {
                log("Before applying");
            }
            ApplySettings();
            ApplyPresets();
            if (Main.settings.DEBUG)
            {
                log("Before after");
            }

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

            Transform         skater_transform = PlayerController.Instance.skaterController.transform;
            List <GameObject> toHide           = new List <GameObject>();
            List <string>     toHide_names     = new List <string>(new string[] {
                "Cory_fixed_Karam:cory_001:body_geo", "Cory_fixed_Karam:cory_001:eyes_geo",
                "Cory_fixed_Karam:cory_001:lacrima_geo", "Cory_fixed_Karam:cory_001:lashes_geo",
                "Cory_fixed_Karam:cory_001:tear_geo", "Cory_fixed_Karam:cory_001:teethDn_geo",
                "Cory_fixed_Karam:cory_001:teethUp_geo", "Cory_fixed_Karam:cory_001:hat_geo"
            });

            for (int i = 0; i < skater_transform.childCount; i++)
            {
                var child = skater_transform.GetChild(i);
                //log("Child: " + child.name);
                for (int j = 0; j < child.childCount; j++)
                {
                    var grandchild = child.GetChild(j);
                    //log("Grand: " + grandchild.name);
                    for (int k = 0; k < grandchild.childCount; k++)
                    {
                        var grandgrandchild = grandchild.GetChild(k);
                        //log("Grandgrand: " + grandgrandchild.name);
                        if (toHide_names.Contains(grandgrandchild.name))
                        {
                            toHide.Add(grandgrandchild.gameObject);
                        }
                    }
                }
            }

            List <string> mat_names = new List <string>(new string[] {
                "UniqueShaders_head_mat (Instance)", "GenericShaders_eyeInner_mat (Instance)",
                "GenericShaders_eyeOuter_mat (Instance)", "GenericShaders_teeth_mat (Instance)",
                "UniqueShaders_hat_mat (Instance)", "GenericShaders_lacrima_mat (Instance)",
                "GenericShaders_lashes_mat (Instance)", "GenericShaders_tear_mat (Instance)"
            });

            customCameraController.standard_shader = Shader.Find("Standard");
            customCameraController.head_shader     = Shader.Find("shaderStandard");
            customCameraController.head_materials  = new List <Material>();
            foreach (var obj in toHide)
            {
                var materials = obj.GetComponent <SkinnedMeshRenderer>().materials;
                for (int k = 0; k < materials.Length; k++)
                {
                    var mat = materials[k];
                    //log("Obj: " + obj.name + ", mat: " + mat.name);
                    if (mat_names.Contains(mat.name))
                    {
                        customCameraController.head_materials.Add(mat);
                    }
                }
            }

            customCameraController.mainCamera = Camera.main;

            if (Main.settings.DEBUG)
            {
                log("Done getSettings");
            }
        }