コード例 #1
0
        public static void SavePreset(bool[] pScenes = null, string name = "preset name")
        {
            Traverse trav = Traverse.Create(phIBL);

            ReflectionProbe probe           = trav.Field("probeComponent").GetValue <ReflectionProbe>();
            int             selectedUserLut = trav.Field("selectedUserLut").GetValue <int>();

            PHIBL.PostProcessing.Utilities.PostProcessingController PPCtrl_obj = trav.Field("PPCtrl").GetValue <PHIBL.PostProcessing.Utilities.PostProcessingController>();

            PresetInfo preset = new PresetInfo
            {
                name              = name,
                scenes            = pScenes,
                profile           = phIBL.Snapshot(),
                nipples           = trav.Field("nippleSSS").GetValue <float>(),
                shadowDistance    = QualitySettings.shadowDistance,
                reflectionBounces = RenderSettings.reflectionBounces,
                probeResolution   = probe.resolution,
                probeIntensity    = probe.intensity,
                enabledLUT        = PPCtrl_obj.enableUserLut,
                selectedLUT       = selectedUserLut,
                contributionLUT   = PPCtrl_obj.userLut.contribution,
                enableDithering   = PPCtrl_obj.enableDither
            };

            File.WriteAllBytes(Directory.GetCurrentDirectory() + "\\Plugins\\PHIBL_PresetLoad\\presets\\" + name + ".preset", LZ4MessagePackSerializer.Serialize(preset, CustomCompositeResolver.Instance));

            SetupPresets();

            Console.WriteLine("[PHIBL_PresetLoad] Saved preset: " + name);
        }
コード例 #2
0
        private static void SetupPresets()
        {
            presets.Clear();
            conflicts.Clear();

            string[] files = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Plugins\\PHIBL_PresetLoad\\presets\\", "*.preset");
            if (files.Length > 0)
            {
                foreach (var filename in files)
                {
                    var file = new FileInfo(filename);
                    if (!file.Exists)
                    {
                        continue;
                    }

                    PresetInfo preset = LZ4MessagePackSerializer.Deserialize <PresetInfo>(File.ReadAllBytes(file.FullName), CustomCompositeResolver.Instance);
                    if (preset != null)
                    {
                        presets.Add(preset);
                    }
                }
            }

            foreach (var preset in presets)
            {
                foreach (var _preset in presets.Where(_preset => preset != _preset))
                {
                    for (int i = 0; i < scenes.Count; i++)
                    {
                        if (!preset.scenes[i] || !_preset.scenes[i])
                        {
                            continue;
                        }

                        conflicts.Add(preset);
                        conflicts.Add(_preset);

                        break;
                    }
                }
            }

            PHIBL_PresetLoad_UI.selectedPreset = -1;
            PHIBL_PresetLoad_UI.presetName     = "preset name";
            PHIBL_PresetLoad_UI.scenes         = new bool[6];
        }
コード例 #3
0
        public static void LoadPreset(int presetID = -1)
        {
            PresetInfo preset = presets.ElementAtOrDefault(presetID);

            if (preset == null)
            {
                return;
            }

            Profile  profile  = preset.profile;
            float    nipples  = preset.nipples;
            Traverse traverse = Traverse.Create(phIBL);

            traverse.Method("LoadPostProcessingProfile", profile).GetValue();
            DeferredShadingUtils deferredShading = traverse.Field("deferredShading").GetValue <DeferredShadingUtils>();

            PHIBL.AlloyDeferredRendererPlus SSSSS = deferredShading.SSSSS;
            Traverse trav = Traverse.Create(SSSSS);

            trav.Field("TransmissionSettings").SetValue(profile.TransmissionSettings);
            trav.Field("SkinSettings").SetValue(profile.SkinSettings);
            trav.Method("Reset").GetValue();
            traverse.Field("phong").SetValue(profile.phong);
            traverse.Field("edgelength").SetValue(profile.edgeLength);
            DeferredShadingUtils.SetTessellation(profile.phong, profile.edgeLength);
            traverse.Field("nippleSSS").SetValue(nipples);
            Shader.SetGlobalFloat(Shader.PropertyToID("_AlphaSSS"), nipples);
            QualitySettings.shadowDistance   = preset.shadowDistance;
            RenderSettings.reflectionBounces = preset.reflectionBounces;
            ReflectionProbe probe = traverse.Field("probeComponent").GetValue <ReflectionProbe>();

            probe.resolution = preset.probeResolution;
            probe.intensity  = preset.probeIntensity;

            PHIBL.PostProcessing.Utilities.PostProcessingController PPCtrl_obj = traverse.Field("PPCtrl").GetValue <PHIBL.PostProcessing.Utilities.PostProcessingController>();
            PPCtrl_obj.enableDither = preset.enableDithering;

            Console.WriteLine("[PHIBL_PresetLoad] Loaded preset: " + presets[presetID].name);
        }
コード例 #4
0
        public static void LoadPreset(int presetID = -1)
        {
            PresetInfo preset = presets.ElementAtOrDefault(presetID);

            if (preset == null)
            {
                return;
            }

            Profile  profile  = preset.profile;
            float    nipples  = preset.nipples;
            Traverse traverse = Traverse.Create(phIBL);

            traverse.Method("LoadPostProcessingProfile", profile).GetValue();
            DeferredShadingUtils deferredShading = traverse.Field("deferredShading").GetValue <DeferredShadingUtils>();

            PHIBL.AlloyDeferredRendererPlus SSSSS = deferredShading.SSSSS;
            Traverse trav = Traverse.Create(SSSSS);

            trav.Field("TransmissionSettings").SetValue(profile.TransmissionSettings);
            trav.Field("SkinSettings").SetValue(profile.SkinSettings);
            trav.Method("Reset").GetValue();
            traverse.Field("phong").SetValue(profile.phong);
            traverse.Field("edgelength").SetValue(profile.edgeLength);
            DeferredShadingUtils.SetTessellation(profile.phong, profile.edgeLength);
            traverse.Field("nippleSSS").SetValue(nipples);
            Shader.SetGlobalFloat(Shader.PropertyToID("_AlphaSSS"), nipples);
            QualitySettings.shadowDistance   = preset.shadowDistance;
            RenderSettings.reflectionBounces = preset.reflectionBounces;
            ReflectionProbe probe = traverse.Field("probeComponent").GetValue <ReflectionProbe>();

            probe.resolution = preset.probeResolution;
            probe.intensity  = preset.probeIntensity;

            var PPCtrl_obj = traverse.Field("PPCtrl").GetValue <PHIBL.PostProcessing.Utilities.PostProcessingController>();

            PPCtrl_obj.enableDither = preset.enableDithering;

            if (preset.enabledLUT)
            {
                string[] names = traverse.Field("LutFileNames").GetValue <string[]>();
                if (names.Length >= preset.selectedLUT)
                {
                    string path = PHIBL.UserData.Path + "PHIBL/Settings/" + names[preset.selectedLUT] + ".png";
                    if (File.Exists(path))
                    {
                        traverse.Field("selectedUserLut").SetValue(preset.selectedLUT);

                        Texture2D texture2D = new Texture2D(1024, 32, TextureFormat.ARGB32, false, true);

                        byte[] Ldata = File.ReadAllBytes(path);
                        texture2D.LoadImage(Ldata);
                        texture2D.filterMode = FilterMode.Trilinear;
                        texture2D.anisoLevel = 0;
                        texture2D.wrapMode   = TextureWrapMode.Repeat;

                        PPCtrl_obj.userLut.lut          = texture2D;
                        PPCtrl_obj.userLut.contribution = preset.contributionLUT;
                        PPCtrl_obj.controlUserLut       = true;
                        PPCtrl_obj.enableUserLut        = true;
                    }
                }
            }
            else
            {
                PPCtrl_obj.enableUserLut = false;
            }

            Console.WriteLine("[PHIBL_PresetLoad] Loaded preset: " + presets[presetID].name);
        }
コード例 #5
0
        private static void DrawWindow(int id)
        {
            GUILayout.BeginHorizontal();

            GUILayout.BeginArea(new Rect(5, 20, uiWidth / 2f - 7, uiHeight - 25), GUI.skin.box);

            GUILayout.BeginVertical();

            presetsScrollPos = GUILayout.BeginScrollView(presetsScrollPos);

            for (int i = 0; i < IPA_PHIBL_PresetLoad.presets.Count; i++)
            {
                GUILayout.BeginHorizontal();

                string name = IPA_PHIBL_PresetLoad.presets[i].name;
                if (selectedPreset == i)
                {
                    name += "<";
                }

                if (IPA_PHIBL_PresetLoad.conflicts.Contains(IPA_PHIBL_PresetLoad.presets[i]))
                {
                    name += " (conflict!)";
                }

                GUILayout.Label(name);

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Select"))
                {
                    PresetInfo preset = IPA_PHIBL_PresetLoad.presets[i];
                    presetName = preset.name;
                    scenes     = preset.scenes;

                    selectedPreset = i;
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();

            if (GUILayout.Button("Load legacy preset"))
            {
                LegacyLoader.LoadPreset();
            }

            GUILayout.EndVertical();

            GUILayout.EndArea();

            GUILayout.BeginArea(new Rect(2 + uiWidth / 2f, 20, uiWidth / 2f - 7, uiHeight - 25), GUI.skin.box);

            GUILayout.BeginVertical();

            presetName = GUILayout.TextField(presetName, 24);
            presetName = Regex.Replace(presetName, @"[^a-zA-Z0-9 _-]", "");

            for (int i = 0; i < scenes.Length; i++)
            {
                if (IPA_PHIBL_PresetLoad.scenes.TryGetValue(i, out var name))
                {
                    scenes[i] = GUILayout.Toggle(scenes[i], name);
                }
            }

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Load preset"))
            {
                IPA_PHIBL_PresetLoad.LoadPreset(selectedPreset);
            }

            if (GUILayout.Button("Delete preset"))
            {
                IPA_PHIBL_PresetLoad.DeletePreset(presetName);
            }

            if (GUILayout.Button("Save preset"))
            {
                IPA_PHIBL_PresetLoad.SavePreset(scenes, presetName);
            }

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.EndArea();

            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }