From 7b29000a70881c8994121d547c055a53dc79b6ef Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Thu, 26 Dec 2024 10:40:59 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editors/AxiProjectTools.cs | 101 +-- .../Script/AppMain/Filter/FilterManager.cs | 646 +++++++++--------- 2 files changed, 373 insertions(+), 374 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs index f531ce2..31e3825 100644 --- a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs +++ b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.IO; @@ -6,6 +6,7 @@ using System.Linq; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; +using UnityEngine.SceneManagement; public class AxiProjectTools : EditorWindow { @@ -28,7 +29,7 @@ public class AxiProjectTools : EditorWindow } } - [MenuItem("Axibugֲ/[1]ɼԤͳµUGUI")] + [MenuItem("Axibug移植工具/[1]采集所有预制体和场景下的UGUI组件")] public static void Part1() { GoTAxiProjectToolsSence(); @@ -42,17 +43,17 @@ public class AxiProjectTools : EditorWindow EditorSceneManager.OpenScene(path); - // һб洢ڵ + // 创建一个列表来存储根节点 List rootNodes = new List(); - // еж + // 遍历场景中的所有对象 GameObject[] allObjects = FindObjectsOfType(); foreach (GameObject obj in allObjects) { - // Ƿи + // 检查对象是否有父对象 if (obj.transform.parent == null) { - // ûиһڵ + // 如果没有父对象,则它是一个根节点 rootNodes.Add(obj); } } @@ -76,7 +77,7 @@ public class AxiProjectTools : EditorWindow AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); GoTAxiProjectToolsSence(); - Debug.Log(" [1]ɼԤͳµUGUI"); + Debug.Log("处理完毕 [1]采集所有预制体和场景下的UGUI组件"); } static void GetPrefab(string path) @@ -102,11 +103,11 @@ public class AxiProjectTools : EditorWindow Type monoType = monoCom.GetType(); if (!monoType.Assembly.FullName.Contains("UnityEngine.UI")) continue; - // ȡMonoScriptԴ + // 获取MonoScript资源 MonoScript monoScript = MonoScript.FromMonoBehaviour(monoCom); if (monoScript != null) { - // ȡMonoScriptԴGUID + // 获取MonoScript资源的GUID string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(monoScript)); Debug.Log($"{nodename} | [{monoType.Name}] {guid}({monoType.FullName})"); ComType2GUID[monoType.FullName] = @@ -119,19 +120,19 @@ public class AxiProjectTools : EditorWindow } else { - Debug.LogError("!!!! û"); + Debug.LogError("!!!! 没得"); } } - // + //遍历 foreach (Transform child in trans.transform) LoopPrefabNode(nodename, child.gameObject, depth + 1); #else - Debug.Log("Ͱ汾Ҫִб"); + Debug.Log("低版本不要执行本函数"); #endif } - [MenuItem("Axibugֲ/[2]мű")] + [MenuItem("Axibug移植工具/[2]生成中间脚本代码")] public static void Part2() { if (UnityEngine.Windows.Directory.Exists(outCsDir)) @@ -151,16 +152,16 @@ public class AxiProjectTools : EditorWindow } catch (Exception ex) { - Debug.LogError("дʧ" + ex.ToString()); + Debug.LogError("写入失败" + ex.ToString()); } } - Debug.Log("д"); + Debug.Log("写入完毕"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); - Debug.Log(" [2]мű"); + Debug.Log("处理完毕 [2]生成中间脚本代码"); } - [MenuItem("Axibugֲ/[3]ռɵĽű")] + [MenuItem("Axibug移植工具/[3]收集生成的脚本")] public static void Part3() { AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath(cachecfgPath); @@ -170,17 +171,17 @@ public class AxiProjectTools : EditorWindow MonoScript monoScript = allMonoScripts.FirstOrDefault(w => w.name == data.ToName); if (monoScript == null) { - Debug.LogError("ûҵ" + data.ToName); + Debug.LogError("没找到" + data.ToName); continue; } string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(monoScript)); data.ToGUID = guid; data.monoScript = monoScript; } - Debug.Log("д"); + Debug.Log("写入完毕"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); - Debug.Log(" [3]ռɵĽű"); + Debug.Log("处理完毕 [3]收集生成的脚本"); } static List FindAllAssetsOfType() where T : UnityEngine.Object @@ -191,7 +192,7 @@ public class AxiProjectTools : EditorWindow foreach (string guid in allGuids) { string path = AssetDatabase.GUIDToAssetPath(guid); - if (path.EndsWith(".cs") || path.EndsWith(".js") || path.EndsWith(".boo")) // Unityֶֽ֧űԣִUnityҪʹC# + if (path.EndsWith(".cs") || path.EndsWith(".js") || path.EndsWith(".boo")) // Unity支持多种脚本语言,但现代Unity主要使用C# { T asset = AssetDatabase.LoadAssetAtPath(path); if (asset != null) @@ -204,7 +205,7 @@ public class AxiProjectTools : EditorWindow } - [MenuItem("Axibugֲ/[4]滻Ԥͳе")] + [MenuItem("Axibug移植工具/[4]替换所有预制体和场景中的组件")] public static void Part4() { AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath(cachecfgPath); @@ -218,7 +219,7 @@ public class AxiProjectTools : EditorWindow ProcessAllPrefabs("*.anim", tempReplaceDict); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); - Debug.Log(" [4]滻Ԥͳе"); + Debug.Log("处理完毕 [4]替换所有预制体和场景中的组件"); } static void ProcessAllPrefabs(string form, Dictionary tempReplaceDict, bool reverse = false) @@ -235,15 +236,15 @@ public class AxiProjectTools : EditorWindow string newValue = reverse ? VARIABLE.Key : VARIABLE.Value; ReplaceValue(absolutePaths[i], oldValue, newValue); } - EditorUtility.DisplayProgressBar("Ԥ塭", "ԤС", (float)i / absolutePaths.Length); + EditorUtility.DisplayProgressBar("处理预制体……", "处理预制体中……", (float)i / absolutePaths.Length); } EditorUtility.ClearProgressBar(); } /// - /// 滻ֵ + /// 替换值 /// - /// ļ· + /// 文件路径 static void ReplaceValue(string strFilePath, string oldLine, string newLine) { if (File.Exists(strFilePath)) @@ -258,7 +259,7 @@ public class AxiProjectTools : EditorWindow } - [MenuItem("Axibugֲ/[5]UnPackǶԤͳеԤ")] + [MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")] public static void UnpackPrefabs() { @@ -276,7 +277,7 @@ public class AxiProjectTools : EditorWindow prefabCount++; } } - Debug.Log($"{prefabCount}ԤUnpack"); + Debug.Log($"{prefabCount}个预制体Unpack"); string[] sceneGuids = AssetDatabase.FindAssets("t:scene"); foreach (string guid in sceneGuids) @@ -290,21 +291,21 @@ public class AxiProjectTools : EditorWindow GameObject[] rootObjects = currentScene.GetRootGameObjects(); foreach (GameObject rootObj in rootObjects) { - // еж + // 遍历场景中的所有对象 TraverseHierarchy(rootObj); } - // Save the scene // ȡǰ򿪵ij + // Save the scene // 获取当前打开的场景 currentScene = EditorSceneManager.GetActiveScene(); - // 泡ļĬ·ƣ + // 保存场景到文件(默认路径和名称) bool success = EditorSceneManager.SaveScene(currentScene, currentScene.path); - Debug.Log($"{currentScene.name} Unpack"); + Debug.Log($"{currentScene.name}场景中 所有物体Unpack"); } GoTAxiProjectToolsSence(); - Debug.Log(" [5]UnPackԤ"); + Debug.Log("处理完毕 [5]UnPack所有预制体"); #else - Debug.Log("Ͱ汾Ҫִб"); + Debug.Log("低版本不要执行本函数"); #endif } @@ -323,33 +324,33 @@ public class AxiProjectTools : EditorWindow PrefabUtility.SaveAsPrefabAsset(obj, prefabPath); GameObject.DestroyImmediate(obj); #else - Debug.Log("Ͱ汾Ҫִб"); + Debug.Log("低版本不要执行本函数"); #endif } static void TraverseHierarchy(GameObject obj) { #if UNITY_2018_4_OR_NEWER - // öǷԤʵ + // 检查该对象是否是预制体的实例 if (PrefabUtility.IsPartOfPrefabInstance(obj)) { - // ԤʵתΪͨϷ + // 将预制体实例转换为普通游戏对象 PrefabUtility.UnpackPrefabInstance(obj, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction); Debug.Log("Prefab instance converted to game object: " + obj.name); } - // ݹӶ + // 递归遍历子对象 for (int i = 0; i < obj.transform.childCount; i++) { TraverseHierarchy(obj.transform.GetChild(i).gameObject); } #else - Debug.Log("Ͱ汾Ҫִб"); + Debug.Log("低版本不要执行本函数"); #endif } - [MenuItem("Axibugֲ/[6]޸Sprite")] + [MenuItem("Axibug移植工具/[6]修复Sprite")] public static void FixMultipleMaterialSprites() { string[] guids = AssetDatabase.FindAssets("t:sprite"); @@ -360,7 +361,7 @@ public class AxiProjectTools : EditorWindow string path = AssetDatabase.GUIDToAssetPath(guid); Sprite sprite = AssetDatabase.LoadAssetAtPath(path); - // Ƿж + // 检查是否有多个材质 if (IsUsingMultipleMaterials(sprite)) { spritesToFix.Add(sprite); @@ -368,7 +369,7 @@ public class AxiProjectTools : EditorWindow } } - // ޸ÿҵSprite + // 修复每个找到的Sprite foreach (var sprite in spritesToFix) { FixSprite(sprite); @@ -376,14 +377,14 @@ public class AxiProjectTools : EditorWindow AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); - Debug.Log(" [6]޸Sprite"); + Debug.Log("处理完毕 [6]修复Sprite"); } private static bool IsUsingMultipleMaterials(Sprite sprite) { if (sprite == null) return false; - // ȡIJ + // 获取精灵的材质 var textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(sprite)) as TextureImporter; return textureImporter != null && textureImporter.spriteImportMode == SpriteImportMode.Multiple; @@ -391,24 +392,24 @@ public class AxiProjectTools : EditorWindow private static void FixSprite(Sprite sprite) { - // ȡSprite· + // 获取Sprite的路径 string path = AssetDatabase.GetAssetPath(sprite); var textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; if (textureImporter != null) { - // 浱ǰиϢ + // 保存当前切割信息 SpriteMetaData[] originalMetaData = textureImporter.spritesheet; - // ʱSprite + // 临时禁用Sprite导入 textureImporter.spriteImportMode = SpriteImportMode.None; textureImporter.SaveAndReimport(); - // Sprite벢ԭи + // 重新启用Sprite导入并保持原样切割参数 textureImporter.spriteImportMode = SpriteImportMode.Multiple; - textureImporter.spritesheet = originalMetaData; // ָԭиϢ + textureImporter.spritesheet = originalMetaData; // 恢复原来的切割信息 - // µӦø + // 重新导入以应用更改 textureImporter.SaveAndReimport(); } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs index bc28153..5721c60 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs @@ -7,19 +7,19 @@ using static AxibugEmuOnline.Client.FilterEffect; namespace AxibugEmuOnline.Client { - public class FilterManager - { - private List m_filters; - private Dictionary m_filterPlatforms = new Dictionary(); - private AlphaWraper m_previewFilterWraper; - FilterRomSetting m_filterRomSetting; - /// - /// 滤镜列表 - /// - public IReadOnlyList Filters => m_filters; + public class FilterManager + { + private List m_filters; + private Dictionary m_filterPlatforms = new Dictionary(); + private AlphaWraper m_previewFilterWraper; + FilterRomSetting m_filterRomSetting; + /// + /// 滤镜列表 + /// + public IReadOnlyList Filters => m_filters; - public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg) - { + public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg) + { #if UNITY_PSP2 m_filters = new List(); m_filterRomSetting = new FilterRomSetting(); @@ -27,376 +27,374 @@ namespace AxibugEmuOnline.Client return; #endif - m_filters = new List - { - new Filter(new FixingPixelArtGrille()), - new Filter(new LCDPostEffect()), - new Filter(new MattiasCRT()), - }; - var json = PlayerPrefs.GetString(nameof(FilterRomSetting)); - m_filterRomSetting = JsonUtility.FromJson(json) ?? new FilterRomSetting(); + m_filters = new List + { + new Filter(new FixingPixelArtGrille()), + new Filter(new LCDPostEffect()), + new Filter(new MattiasCRT()), + }; + var json = PlayerPrefs.GetString(nameof(FilterRomSetting)); + m_filterRomSetting = JsonUtility.FromJson(json) ?? new FilterRomSetting(); - m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false); - ShutDownFilterPreview(); - ShutDownFilter(); - } + m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false); + ShutDownFilterPreview(); + ShutDownFilter(); + } - private RenderTexture result = null; - public Texture ExecuteFilterRender(Texture src) - { - if (result == null) - { - //result = RenderTexture.GetTemporary(Screen.width, Screen.height); - result = Initer.instance.renderTest; - } - else if (result.width != Screen.width || result.height != Screen.height) - { - //RenderTexture.ReleaseTemporary(result); - //result = RenderTexture.GetTemporary(Screen.width, Screen.height); - result = Initer.instance.renderTest; - } + private RenderTexture result = null; + public Texture ExecuteFilterRender(Texture src) + { + if (result == null) + { + result = RenderTexture.GetTemporary(Screen.width, Screen.height); + } + else if (result.width != Screen.width || result.height != Screen.height) + { + RenderTexture.ReleaseTemporary(result); + result = RenderTexture.GetTemporary(Screen.width, Screen.height); + } - bool anyFilterEnable = false; - foreach (var filter in Filters) - { - if (!filter.m_setting.Enable.GetValue()) continue; - filter.m_setting.Render(src, result); - anyFilterEnable = true; - } + bool anyFilterEnable = false; + foreach (var filter in Filters) + { + if (!filter.m_setting.Enable.GetValue()) continue; + filter.m_setting.Render(src, result); + anyFilterEnable = true; + } - if (anyFilterEnable) - return result; - else - return src; - } + if (anyFilterEnable) + return result; + else + return src; + } - /// 关闭滤镜预览 - public void ShutDownFilterPreview() - { - m_previewFilterWraper.On = false; - } + /// 关闭滤镜预览 + public void ShutDownFilterPreview() + { + m_previewFilterWraper.On = false; + } - /// 开启滤镜预览 - public void EnableFilterPreview() - { - m_previewFilterWraper.On = true; - } + /// 开启滤镜预览 + public void EnableFilterPreview() + { + m_previewFilterWraper.On = true; + } - /// - /// 打开滤镜 - /// - /// - public void EnableFilter(Filter filter) - { - foreach (var selfFiler in Filters) - { - if (selfFiler != filter) selfFiler.m_setting.Enable.Override(false); - else selfFiler.m_setting.Enable.Override(true); - } - } + /// + /// 打开滤镜 + /// + /// + public void EnableFilter(Filter filter) + { + foreach (var selfFiler in Filters) + { + if (selfFiler != filter) selfFiler.m_setting.Enable.Override(false); + else selfFiler.m_setting.Enable.Override(true); + } + } - /// - /// 关闭滤镜效果 - /// - public void ShutDownFilter() - { - //关闭所有后处理效果 - foreach (var filter in Filters) - filter.m_setting.Enable.Override(false); - } + /// + /// 关闭滤镜效果 + /// + public void ShutDownFilter() + { + //关闭所有后处理效果 + foreach (var filter in Filters) + filter.m_setting.Enable.Override(false); + } - /// - /// 为指定rom设置滤镜以及滤镜的预设 - /// - /// rom对象 - /// 滤镜 - /// 滤镜预设 - public void SetupFilter(RomFile rom, Filter filter, FilterPreset preset) - { - m_filterRomSetting.Setup(rom, filter, preset); + /// + /// 为指定rom设置滤镜以及滤镜的预设 + /// + /// rom对象 + /// 滤镜 + /// 滤镜预设 + public void SetupFilter(RomFile rom, Filter filter, FilterPreset preset) + { + m_filterRomSetting.Setup(rom, filter, preset); - string json = m_filterRomSetting.ToJson(); - PlayerPrefs.SetString(nameof(FilterRomSetting), json); - } + string json = m_filterRomSetting.ToJson(); + PlayerPrefs.SetString(nameof(FilterRomSetting), json); + } - /// - /// 获得指定rom配置的滤镜设置 - /// - /// rom对象 - /// 此元组任意内任意成员都有可能为空 - public GetFilterSetting_result GetFilterSetting(RomFile rom) - { - var value = m_filterRomSetting.Get(rom); - Filter filter = null; - FilterPreset preset = null; + /// + /// 获得指定rom配置的滤镜设置 + /// + /// rom对象 + /// 此元组任意内任意成员都有可能为空 + public GetFilterSetting_result GetFilterSetting(RomFile rom) + { + var value = m_filterRomSetting.Get(rom); + Filter filter = null; + FilterPreset preset = null; - //filter = Filters.FirstOrDefault(f => f.Name == value.filterName); - //if (filter != null) - //{ - // string presetName = value.presetName; - // preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); - //} + //filter = Filters.FirstOrDefault(f => f.Name == value.filterName); + //if (filter != null) + //{ + // string presetName = value.presetName; + // preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); + //} - filter = Filters.FirstOrDefault(f => f.Name == value.Item1); - if (filter != null) - { - string presetName = value.Item2; - preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); - } + filter = Filters.FirstOrDefault(f => f.Name == value.Item1); + if (filter != null) + { + string presetName = value.Item2; + preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); + } - return new GetFilterSetting_result() - { - filter = filter, - preset = preset - }; - } + return new GetFilterSetting_result() + { + filter = filter, + preset = preset + }; + } - public struct GetFilterSetting_result - { - public Filter filter; - public FilterPreset preset; - } + public struct GetFilterSetting_result + { + public Filter filter; + public FilterPreset preset; + } - public class Filter - { - public string Name => m_setting.Name; - public IReadOnlyCollection Paramerters => m_setting.EditableParam; - /// 滤镜预设 - public List Presets = new List(); - /// 滤镜默认预设 - public FilterPreset DefaultPreset = new FilterPreset("DEFAULT"); + public class Filter + { + public string Name => m_setting.Name; + public IReadOnlyCollection Paramerters => m_setting.EditableParam; + /// 滤镜预设 + public List Presets = new List(); + /// 滤镜默认预设 + public FilterPreset DefaultPreset = new FilterPreset("DEFAULT"); - internal FilterEffect m_setting; + internal FilterEffect m_setting; - public Filter(FilterEffect setting) - { - m_setting = setting; + public Filter(FilterEffect setting) + { + m_setting = setting; - loadPresets(); - } + loadPresets(); + } - private void loadPresets() - { - var json = PlayerPrefs.GetString($"Filter_{Name}_PresetList", string.Empty); - var loadedPresets = JsonUtility.FromJson(json); - if (loadedPresets == null) return; - else Presets = loadedPresets.presets; - } + private void loadPresets() + { + var json = PlayerPrefs.GetString($"Filter_{Name}_PresetList", string.Empty); + var loadedPresets = JsonUtility.FromJson(json); + if (loadedPresets == null) return; + else Presets = loadedPresets.presets; + } - public void SavePresets() - { - var json = JsonUtility.ToJson(new FilterPresetList(Presets)); - PlayerPrefs.SetString($"Filter_{Name}_PresetList", json); - } + public void SavePresets() + { + var json = JsonUtility.ToJson(new FilterPresetList(Presets)); + PlayerPrefs.SetString($"Filter_{Name}_PresetList", json); + } - public MsgBool CreatePreset(string presetName, out FilterPreset newPreset) - { - newPreset = null; - if (string.IsNullOrWhiteSpace(presetName)) return "名称不能为空"; - if (Presets.Count(p => p.Name == presetName) != 0) return "名称重复"; + public MsgBool CreatePreset(string presetName, out FilterPreset newPreset) + { + newPreset = null; + if (string.IsNullOrWhiteSpace(presetName)) return "名称不能为空"; + if (Presets.Count(p => p.Name == presetName) != 0) return "名称重复"; - newPreset = new FilterPreset(presetName); - Presets.Add(newPreset); + newPreset = new FilterPreset(presetName); + Presets.Add(newPreset); - SavePresets(); + SavePresets(); - return true; - } + return true; + } - public void RemovePreset(FilterPreset preset) - { - if (!Presets.Remove(preset)) return; - SavePresets(); + public void RemovePreset(FilterPreset preset) + { + if (!Presets.Remove(preset)) return; + SavePresets(); - EventInvoker.RaiseFilterPresetRemoved(this, preset); - } + EventInvoker.RaiseFilterPresetRemoved(this, preset); + } - public void ResetPreset() - { - foreach (var param in Paramerters) - { - param.ResetToDefault(); - } - } + public void ResetPreset() + { + foreach (var param in Paramerters) + { + param.ResetToDefault(); + } + } - public void ApplyPreset(FilterPreset preset) - { - foreach (var param in Paramerters) - { - var value = preset.GetParamValue(param.Name, param.ValueType); - if (value == null) - param.ResetToDefault(); - else - param.Apply(value); - } + public void ApplyPreset(FilterPreset preset) + { + foreach (var param in Paramerters) + { + var value = preset.GetParamValue(param.Name, param.ValueType); + if (value == null) + param.ResetToDefault(); + else + param.Apply(value); + } - } + } - } + } - [Serializable] - private class FilterPresetList - { - public List presets; + [Serializable] + private class FilterPresetList + { + public List presets; - public FilterPresetList(List presets) - { - this.presets = presets; - foreach (var preset in presets) - { - preset.ReadyForJson(); - } - } - } + public FilterPresetList(List presets) + { + this.presets = presets; + foreach (var preset in presets) + { + preset.ReadyForJson(); + } + } + } - [Serializable] - public class FilterPreset - { - [SerializeField] - public string Name; - [SerializeField] - private List m_paramName = new List(); - [SerializeField] - private List m_valueJson = new List(); + [Serializable] + public class FilterPreset + { + [SerializeField] + public string Name; + [SerializeField] + private List m_paramName = new List(); + [SerializeField] + private List m_valueJson = new List(); - private bool m_cacheReady = false; - private Dictionary m_paramName2ValueJson; - public FilterPreset(string presetName) - { - Name = presetName; - } + private bool m_cacheReady = false; + private Dictionary m_paramName2ValueJson; + public FilterPreset(string presetName) + { + Name = presetName; + } - public void ReadyForJson() - { - prepareCache(); + public void ReadyForJson() + { + prepareCache(); - m_paramName = m_paramName2ValueJson.Keys.ToList(); - m_valueJson = m_paramName2ValueJson.Values.ToList(); - } + m_paramName = m_paramName2ValueJson.Keys.ToList(); + m_valueJson = m_paramName2ValueJson.Values.ToList(); + } - public string GetParamValueJson(string paramName) - { - prepareCache(); - string value; - m_paramName2ValueJson.TryGetValue(paramName, out value); - return value; - } + public string GetParamValueJson(string paramName) + { + prepareCache(); + string value; + m_paramName2ValueJson.TryGetValue(paramName, out value); + return value; + } - public object GetParamValue(string paramName, Type valueType) - { - var rawStr = GetParamValueJson(paramName); - if (rawStr == null) return null; + public object GetParamValue(string paramName, Type valueType) + { + var rawStr = GetParamValueJson(paramName); + if (rawStr == null) return null; - if (valueType == typeof(float)) - { - float floatVal; - float.TryParse(rawStr, out floatVal); - return floatVal; - } - else if (valueType.IsEnum) - { - var names = Enum.GetNames(valueType); - var values = Enum.GetValues(valueType); + if (valueType == typeof(float)) + { + float floatVal; + float.TryParse(rawStr, out floatVal); + return floatVal; + } + else if (valueType.IsEnum) + { + var names = Enum.GetNames(valueType); + var values = Enum.GetValues(valueType); - for (int i = 0; i < names.Length; i++) - { - if (names[i].Equals(rawStr)) - { - return values.GetValue(i); - } - } - return null; - } - else - { - App.log.Error($"尚未支持的滤镜参数类型{valueType}"); - return null; - } - } + for (int i = 0; i < names.Length; i++) + { + if (names[i].Equals(rawStr)) + { + return values.GetValue(i); + } + } + return null; + } + else + { + App.log.Error($"尚未支持的滤镜参数类型{valueType}"); + return null; + } + } - public void SetParamValue(string paramName, Type valueType, object value) - { - prepareCache(); - m_paramName2ValueJson[paramName] = value.ToString(); - } + public void SetParamValue(string paramName, Type valueType, object value) + { + prepareCache(); + m_paramName2ValueJson[paramName] = value.ToString(); + } - private void prepareCache() - { - if (m_cacheReady) return; + private void prepareCache() + { + if (m_cacheReady) return; - m_paramName2ValueJson = new Dictionary(); - for (int i = 0; i < m_paramName.Count; i++) - { - m_paramName2ValueJson[m_paramName[i]] = m_valueJson[i]; - } + m_paramName2ValueJson = new Dictionary(); + for (int i = 0; i < m_paramName.Count; i++) + { + m_paramName2ValueJson[m_paramName[i]] = m_valueJson[i]; + } - m_cacheReady = true; - } - } + m_cacheReady = true; + } + } - [Serializable] - public class FilterRomSetting - { - [SerializeField] - private List m_romID; - [SerializeField] - private List m_items; + [Serializable] + public class FilterRomSetting + { + [SerializeField] + private List m_romID; + [SerializeField] + private List m_items; - bool m_cacheReady = false; - Dictionary m_cache; + bool m_cacheReady = false; + Dictionary m_cache; - public void Setup(RomFile rom, Filter filter, FilterPreset preset) - { - prepareCache(); + public void Setup(RomFile rom, Filter filter, FilterPreset preset) + { + prepareCache(); - if (filter == null) - m_cache.Remove(rom.ID); - else - m_cache[rom.ID] = new Item { FilterName = filter.Name, PresetName = preset != null ? preset.Name : null }; - } + if (filter == null) + m_cache.Remove(rom.ID); + else + m_cache[rom.ID] = new Item { FilterName = filter.Name, PresetName = preset != null ? preset.Name : null }; + } - public string ToJson() - { - prepareCache(); - m_romID = m_cache.Keys.ToList(); - m_items = m_cache.Values.ToList(); + public string ToJson() + { + prepareCache(); + m_romID = m_cache.Keys.ToList(); + m_items = m_cache.Values.ToList(); - return JsonUtility.ToJson(this); - } + return JsonUtility.ToJson(this); + } - public ValueTuple Get(RomFile rom) - { - prepareCache(); + public ValueTuple Get(RomFile rom) + { + prepareCache(); - Item item; - m_cache.TryGetValue(rom.ID, out item); - return new ValueTuple(item.FilterName, item.PresetName); - } + Item item; + m_cache.TryGetValue(rom.ID, out item); + return new ValueTuple(item.FilterName, item.PresetName); + } - private void prepareCache() - { - if (m_cacheReady) return; + private void prepareCache() + { + if (m_cacheReady) return; - if (m_items == null) m_items = new List(); - if (m_romID == null) m_romID = new List(); - m_cache = new Dictionary(); - for (int i = 0; i < m_romID.Count && i < m_items.Count; i++) - { - m_cache[m_romID[i]] = m_items[i]; - } + if (m_items == null) m_items = new List(); + if (m_romID == null) m_romID = new List(); + m_cache = new Dictionary(); + for (int i = 0; i < m_romID.Count && i < m_items.Count; i++) + { + m_cache[m_romID[i]] = m_items[i]; + } - m_cacheReady = true; - } + m_cacheReady = true; + } - [Serializable] - struct Item - { - public string FilterName; - public string PresetName; - } - } - } + [Serializable] + struct Item + { + public string FilterName; + public string PresetName; + } + } + } } From 9fb1812266faee6ebca085539aa02c1518e39419 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Thu, 26 Dec 2024 14:14:13 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8A=A0bom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/AxiProjectTools/Editors/AxiPrefabCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs index 81aabc6..898c650 100644 --- a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs +++ b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using UnityEditor; From 710359f538e9cd5dd71fc311d971fdd675bed291 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Thu, 26 Dec 2024 15:20:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?MattiasCRT=E5=A2=9E=E5=8A=A0=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E8=B4=A8=E9=87=8F=E5=8F=98=E4=BD=93,=E4=BC=98?= =?UTF-8?q?=E5=8C=96MattiasCRT=20render=E4=BB=A3=E7=A0=81=E6=95=88?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Script/AppMain/Filter/FilterEffect.cs | 4 ++ .../Filter/LCDPostEffect/LCDPostEffect.cs | 2 +- .../AppMain/Filter/MattiasCRT/MattiasCRT.cs | 37 ++++++++++++++++++- .../Filter/MattiasCRT/MattiasCRT.shader | 19 ++++++++-- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs index 9ec1ef0..e159f07 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs @@ -22,7 +22,11 @@ namespace AxibugEmuOnline.Client { GetEditableFilterParamters(); m_material = new Material(Shader.Find(ShaderName)); + OnInit(m_material); } + + protected virtual void OnInit(Material renderMat) { } + void GetEditableFilterParamters() { var parameters = (from t in GetType().GetFields(BindingFlags.Instance | BindingFlags.Public) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs index f8ccca3..fe91ac5 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/LCDPostEffect/LCDPostEffect.cs @@ -9,7 +9,7 @@ public sealed class LCDPostEffect : FilterEffect protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result) { - renderMat.SetVector("_iResolution", new Vector4(Screen.width, Screen.height, 0, 0)); + renderMat.SetVector("_iResolution", new Vector4(result.width, result.height, 0, 0)); Graphics.Blit(src, result, renderMat); } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs index 6e6c79d..d6400f3 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs @@ -1,5 +1,7 @@ -using AxibugEmuOnline.Client; +using Assets.Script.AppMain.Filter; +using AxibugEmuOnline.Client; using UnityEngine; +using UnityEngine.Rendering; public sealed class MattiasCRT : FilterEffect { @@ -7,9 +9,40 @@ public sealed class MattiasCRT : FilterEffect protected override string ShaderName => "Filter/MattiasCRT"; + public FilterParameter Quality = new FilterParameter(EnumQuality.High); + private LocalKeyword _kw_qualityLow; + private LocalKeyword _kw_qualityMid; + private LocalKeyword _kw_qualityHigh; + private int _pid_iResolution; + + protected override void OnInit(Material renderMat) + { + _pid_iResolution = Shader.PropertyToID("_iResolution"); + _kw_qualityLow = new LocalKeyword(renderMat.shader, "_QUALITY_LOW"); + _kw_qualityMid = new LocalKeyword(renderMat.shader, "_QUALITY_MID"); + _kw_qualityHigh = new LocalKeyword(renderMat.shader, "_QUALITY_HIGH"); + } + protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result) { - renderMat.SetVector("_iResolution", new Vector4(result.width, result.height, 0, 0)); + renderMat.SetVector(_pid_iResolution, new Vector4(result.width, result.height, 0, 0)); + renderMat.DisableKeyword(_kw_qualityLow); + renderMat.DisableKeyword(_kw_qualityMid); + renderMat.DisableKeyword(_kw_qualityHigh); + switch (Quality.GetValue()) + { + case EnumQuality.Low: renderMat.EnableKeyword(_kw_qualityLow); break; + case EnumQuality.Mid: renderMat.EnableKeyword(_kw_qualityMid); break; + case EnumQuality.High: renderMat.EnableKeyword(_kw_qualityHigh); break; + } + Graphics.Blit(src, result, renderMat); } + + public enum EnumQuality + { + Low, + Mid, + High + } } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader index a493754..d0ec3c2 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader @@ -1,4 +1,4 @@ - + Shader "Filter/MattiasCRT" { Properties @@ -11,6 +11,7 @@ Shader "Filter/MattiasCRT" { CGPROGRAM + #pragma shader_feature_local _QUALITY_LOW _QUALITY_MID _QUALITY_HIGH #pragma vertex vert_img #pragma fragment frag #include "UnityCG.cginc" @@ -37,16 +38,26 @@ Shader "Filter/MattiasCRT" float2 q = fragCoord.xy / _iResolution.xy; float2 uv = q; uv = curve( uv ); - float3 oricol = tex2D(_MainTex,uv).xyz; - float3 col; float x = sin(0.3*_Time+uv.y*21.0)*sin(0.7*_Time+uv.y*29.0)*sin(0.3+0.33*_Time+uv.y*31.0)*0.0017; + float3 col; + #if _QUALITY_LOW + col = tex2D(_MainTex,uv); + #elif _QUALITY_MID + col = tex2D(_MainTex,float2(x+uv.x+0.001,uv.y+0.001))+0.05; + float3 tmpColor2 = tex2D(_MainTex,0.75*float2(x+0.025, -0.027)+float2(uv.x+0.001,uv.y+0.001)); + col.r+=tmpColor2.x*0.08; + col.g+=tmpColor2.y*0.05; + col.b+=tmpColor2.z*0.08; + #else col.r = tex2D(_MainTex,float2(x+uv.x+0.001,uv.y+0.001)).x+0.05; col.g = tex2D(_MainTex,float2(x+uv.x+0.000,uv.y-0.002)).y+0.05; col.b = tex2D(_MainTex,float2(x+uv.x-0.002,uv.y+0.000)).z+0.05; col.r += 0.08*tex2D(_MainTex,0.75*float2(x+0.025, -0.027)+float2(uv.x+0.001,uv.y+0.001)).x; - col.g += 0.05*tex2D(_MainTex,0.75*float2(x+-0.022, -0.02)+float2(uv.x+0.000,uv.y-0.002)).y; col.b += 0.08*tex2D(_MainTex,0.75*float2(x+-0.02, -0.018)+float2(uv.x-0.002,uv.y+0.000)).z; + col.g += 0.05*tex2D(_MainTex,0.75*float2(x+-0.022, -0.02)+float2(uv.x+0.000,uv.y-0.002)).y; + #endif + col = clamp(col*0.6+0.4*col*col*1.0,0.0,1.0); From c254f0f5bbd59f49a9ed488feb593c09d94fae0f Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Thu, 26 Dec 2024 20:34:56 +0800 Subject: [PATCH 4/5] =?UTF-8?q?shader=E5=AE=9E=E9=AA=8C=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIEffect/Materials/UI-Effect.mat | 70 ++- .../Assets/Scene/AxibugEmuOnline.Client.unity | 16 + .../Assets/Scene/TestFilter.unity | 554 ++++++++++++++++++ .../Assets/Scene/TestFilter.unity.meta | 7 + .../Filter/FilterShaderTemplate.shader | 36 ++ .../Filter/FilterShaderTemplate.shader.meta | 9 + .../Filter/MattiasCRT/MattiasCRT.shader | 1 + .../Script/AppMain/Filter/RetroArch_Glow.meta | 8 + .../Filter/RetroArch_Glow/RetroArch_Glow.mat | 86 +++ .../RetroArch_Glow/RetroArch_Glow.mat.meta | 8 + .../RetroArch_Glow/RetroArch_Glow.shader | 307 ++++++++++ .../RetroArch_Glow/RetroArch_Glow.shader.meta | 9 + .../Filter/RetroArch_Glow/blur_params.cginc | 4 + .../RetroArch_Glow/blur_params.cginc.meta | 7 + .../Assets/Script/TestFilter.cs | 50 ++ .../Assets/Script/TestFilter.cs.meta | 2 + 16 files changed, 1168 insertions(+), 6 deletions(-) create mode 100644 AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity create mode 100644 AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity.meta create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader.meta create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow.meta create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat.meta create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader.meta create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc.meta create mode 100644 AxibugEmuOnline.Client/Assets/Script/TestFilter.cs create mode 100644 AxibugEmuOnline.Client/Assets/Script/TestFilter.cs.meta diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Coffee/UIExtensions/UIEffect/Materials/UI-Effect.mat b/AxibugEmuOnline.Client/Assets/Plugins/Coffee/UIExtensions/UIEffect/Materials/UI-Effect.mat index 3c3817e..75ab7d0 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Coffee/UIExtensions/UIEffect/Materials/UI-Effect.mat +++ b/AxibugEmuOnline.Client/Assets/Plugins/Coffee/UIExtensions/UIEffect/Materials/UI-Effect.mat @@ -451,7 +451,8 @@ Material: m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] + m_ValidKeywords: + - DETAILBLUR m_InvalidKeywords: [] m_LightmapFlags: 5 m_EnableInstancingVariants: 0 @@ -2530,7 +2531,9 @@ Material: m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] + m_ValidKeywords: + - EX + - MEDIUMBLUR m_InvalidKeywords: [] m_LightmapFlags: 5 m_EnableInstancingVariants: 0 @@ -2998,7 +3001,9 @@ Material: m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] + m_ValidKeywords: + - DETAILBLUR + - EX m_InvalidKeywords: [] m_LightmapFlags: 5 m_EnableInstancingVariants: 0 @@ -3202,7 +3207,8 @@ Material: m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] + m_ValidKeywords: + - FASTBLUR m_InvalidKeywords: [] m_LightmapFlags: 5 m_EnableInstancingVariants: 0 @@ -3646,7 +3652,9 @@ Material: m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] + m_ValidKeywords: + - EX + - FASTBLUR m_InvalidKeywords: [] m_LightmapFlags: 5 m_EnableInstancingVariants: 0 @@ -4922,7 +4930,10 @@ Material: m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3} m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] + m_ValidKeywords: + - DETAILBLUR + - EX + - GRAYSCALE m_InvalidKeywords: [] m_LightmapFlags: 5 m_EnableInstancingVariants: 0 @@ -5607,6 +5618,53 @@ Material: - _Color: {r: 1, g: 1, b: 1, a: 1} m_BuildTextureStacks: [] m_AllowLocking: 1 +--- !u!21 &823716364251377293 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 9 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UI-Effect-Sepia-DetailBlur-Ex + m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: + - DETAILBLUR + - EX + - SEPIA + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParamTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _ColorMask: 15 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 + - _UseUIAlphaClip: 0 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + m_BuildTextureStacks: [] + m_AllowLocking: 1 --- !u!21 &3053942024298246613 Material: serializedVersion: 8 diff --git a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity index f1ceb1f..1c5d6cb 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity @@ -1326,6 +1326,14 @@ PrefabInstance: propertyPath: m_AnchoredPosition.x value: 0 objectReference: {fileID: 0} + - target: {fileID: 2521876046310890063, guid: 3b211f31b55a35e44a8fa38666f63383, type: 3} + propertyPath: m_AnchoredPosition.x + value: 30.929993 + objectReference: {fileID: 0} + - target: {fileID: 2522900033012761306, guid: 3b211f31b55a35e44a8fa38666f63383, type: 3} + propertyPath: m_AnchoredPosition.x + value: 30.929993 + objectReference: {fileID: 0} - target: {fileID: 2580867844924924490, guid: 3b211f31b55a35e44a8fa38666f63383, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -1374,6 +1382,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.x value: 0 objectReference: {fileID: 0} + - target: {fileID: 2873860005477794326, guid: 3b211f31b55a35e44a8fa38666f63383, type: 3} + propertyPath: m_AnchoredPosition.x + value: 30.929993 + objectReference: {fileID: 0} - target: {fileID: 2921874279820016524, guid: 3b211f31b55a35e44a8fa38666f63383, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -1426,6 +1438,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 3084872378777530071, guid: 3b211f31b55a35e44a8fa38666f63383, type: 3} + propertyPath: m_AnchoredPosition.x + value: 30.929993 + objectReference: {fileID: 0} - target: {fileID: 3201409976408832832, guid: 3b211f31b55a35e44a8fa38666f63383, type: 3} propertyPath: m_AnchorMax.y value: 0 diff --git a/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity b/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity new file mode 100644 index 0000000..4b2bf66 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity @@ -0,0 +1,554 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 10 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.4292453, g: 0.5907795, b: 1, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 13 + m_BakeOnSceneLoad: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 1 + m_PVRFilteringGaussRadiusAO: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &33805169 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 33805170} + - component: {fileID: 33805172} + - component: {fileID: 33805171} + m_Layer: 5 + m_Name: Image (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &33805170 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 33805169} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1319295996} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &33805171 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 33805169} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: e043954733c440645ba43b09301ee4a6, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &33805172 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 33805169} + m_CullTransparentMesh: 1 +--- !u!1 &141076932 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 141076935} + - component: {fileID: 141076934} + - component: {fileID: 141076933} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &141076933 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 141076932} + m_Enabled: 1 +--- !u!20 &141076934 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 141076932} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &141076935 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 141076932} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -5.3346887, y: -4.3005414, z: 3715.6099} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1319295992 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1319295996} + - component: {fileID: 1319295995} + - component: {fileID: 1319295994} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1319295994 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1319295992} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!223 &1319295995 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1319295992} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 1 + m_Camera: {fileID: 141076934} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 + m_AdditionalShaderChannelsFlag: 1 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1319295996 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1319295992} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 33805170} + - {fileID: 1376779137} + - {fileID: 1373072004} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1373072003 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1373072004} + - component: {fileID: 1373072006} + - component: {fileID: 1373072005} + m_Layer: 5 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &1373072004 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1373072003} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1319295996} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 318.00003, y: 179} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1373072005 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1373072003} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e96dacbf1b116f64da658fbad66839e2, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Texture: {fileID: 0} + m_UVRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_EffectFactor: 1 + m_ColorFactor: 1 + m_BlurFactor: 1 + m_EffectMode: 0 + m_ColorMode: 0 + m_BlurMode: 3 + m_EffectColor: {r: 1, g: 1, b: 1, a: 1} + m_DesamplingRate: 1 + m_ReductionRate: 1 + m_FilterMode: 1 + m_EffectMaterial: {fileID: 21380876918929932, guid: 1a1a8e44196ca754a9a7b9cb80e17573, type: 2} + m_BlurIterations: 3 + m_FitToScreen: 1 + m_CaptureOnEnable: 0 +--- !u!222 &1373072006 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1373072003} + m_CullTransparentMesh: 1 +--- !u!1 &1376779136 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1376779137} + - component: {fileID: 1376779139} + - component: {fileID: 1376779140} + - component: {fileID: 1376779141} + m_Layer: 5 + m_Name: filter + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1376779137 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1376779136} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1319295996} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1376779139 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1376779136} + m_CullTransparentMesh: 1 +--- !u!114 &1376779140 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1376779136} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 40d1396d19f4da44f98dd2fcf6f0bc56, type: 3} + m_Name: + m_EditorClassIdentifier: + filterMat: {fileID: 2100000, guid: 5965751351debd6499aa27660a1bc92e, type: 2} + img: {fileID: 1376779141} + source: {fileID: 2800000, guid: e043954733c440645ba43b09301ee4a6, type: 3} +--- !u!114 &1376779141 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1376779136} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Texture: {fileID: 0} + m_UVRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 141076935} + - {fileID: 1319295996} diff --git a/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity.meta b/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity.meta new file mode 100644 index 0000000..ede26b3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7053096623e85d842aa0a92bcc9944ea +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader new file mode 100644 index 0000000..f76643c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader @@ -0,0 +1,36 @@ + +Shader "Hidden/TEMPLATE" +{ + Properties + { + _MainTex ("Base (RGB)", 2D) = "white" {} + } + SubShader + { + Pass + { + CGPROGRAM + + #pragma vertex vert_img + #pragma fragment frag + #include "UnityCG.cginc" + + sampler2D _MainTex; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + fixed4 frag (v2f i) : SV_Target + { + return fixed4(1,1,1,1); + } + ENDCG + } + } +} + + + diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader.meta new file mode 100644 index 0000000..f1ae649 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterShaderTemplate.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 28e36f59e5007bc45bf2ab9d1ad62a02 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader index d0ec3c2..56ece40 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader @@ -33,6 +33,7 @@ Shader "Filter/MattiasCRT" float4 mainImage( float2 fragCoord ) { + float4 fragColor = float4(0,0,0,1); float2 q = fragCoord.xy / _iResolution.xy; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow.meta new file mode 100644 index 0000000..beac7d4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 59751f7f4dc560f47b438056fbc26701 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat new file mode 100644 index 0000000..494c0bb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: RetroArch_Glow + m_Shader: {fileID: 4800000, guid: d9ec870308fa2594badb4f3036d36fd5, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + - _gamma: 2.24 + - _horiz_gauss_width: 1.89 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat.meta new file mode 100644 index 0000000..0be4b59 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5965751351debd6499aa27660a1bc92e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader new file mode 100644 index 0000000..bab00f0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader @@ -0,0 +1,307 @@ +Shader "Filter/RetroArch/Glow" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" + _gamma("Input Gamma option: 2.4/2.0/2.6/0.02",float) = 2.4 + _horiz_gauss_width("Gaussian Width option: 0.5/0.4/0.6/0.02",float) = 0.5 + _BOOST("Color Boost option: 1.0/0.5/1.5/0.02",float) = 1.0 + _GLOW_WHITEPOINT("Glow Whitepoint option: 1.0/0.5/1.1/0.02",float) = 1.0 + _GLOW_ROLLOFF("Glow Rolloff option: 3.0 1.2 6.0 0.1",float) = 3.0 + _BLOOM_STRENGTH("Glow Strength option: 0.45/0.0/0.8/0.05",float) = 0.45 + _OUTPUT_GAMMA("Monitor Gamma option: 2.2/1.8/2.6/0.02",float) = 2.2 + } + SubShader + { + Pass + { + Name "linearize" + + CGPROGRAM + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + half _gamma; + sampler2D _MainTex; + float2 _iResolution; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + + fixed4 frag(v2f i) : SV_Target + { + fixed3 color = tex2D(_MainTex,i.uv); + fixed4 result = fixed4(pow(color,_gamma),1.0); + return result; + } + ENDCG + } + + Pass + { + Name "gauss_horiz" + + CGPROGRAM + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + #define INV_SQRT_2_PI 0.38 + + sampler2D _MainTex; + float2 _iResolution; + float _horiz_gauss_width; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + fixed4 gauss_horiz(v2f IN){ + float one = 1.0/_iResolution.x; + float pix_no = _iResolution.x*IN.uv.x; + float texel = floor(pix_no); + float phase = pix_no-texel; + float base_phase = phase - 0.5; + float2 tex = float2((texel+0.5)/_iResolution.x,IN.uv.y); + + #define TEX(off_x) tex2D(_MainTex, IN.uv + float2(float(off_x) * one, 0.0)).rgb + + float3 col = float3(0,0,0); + for(int i=-2;i<=2;i++){ + float phase = base_phase - float(i); + float g = INV_SQRT_2_PI * exp(-0.5 * phase * phase / (_horiz_gauss_width * _horiz_gauss_width)) / _horiz_gauss_width; + col+=TEX(i)*g; + } + + return fixed4(col,1); + } + + fixed4 frag (v2f i) : SV_Target + { + fixed4 color=gauss_horiz(i); + + return color; + } + ENDCG + } + + Pass + { + Name "gauss_vert" + + CGPROGRAM + + #pragma shader_feature_local _CRT_GEOM_ON _CRT_GEOM_OFF + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + sampler2D _MainTex; + float2 _iResolution; + float _BOOST; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + float3 beam(float3 color,float dist){ + #if CRT_GEOM_BEAM + float3 wid = 2.0 + 2.0 * pow(color, 4.0); + float3 weights = float3(abs(dist) / 0.3); + return 2.0 * color * exp(-pow(weights * rsqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid); + #else + const float width = 0.25; + float3 x = dist / width; + return 2.0 * color * exp(-0.5 * x * x) / width; + #endif + } + + fixed4 frag(v2f IN) : SV_Target + { + float2 pix_no = IN.uv*_iResolution - float2(0,0.5); + float one = 1.0/ _iResolution.y; + + #define TEX(off_y) tex2D(_MainTex, IN.uv + float2(0.0, off_y * one)).rgb + + float2 texel = floor(pix_no); + float phase = pix_no.y - texel.y; + float2 tex = float2(texel + 0.5) / _iResolution; + + float3 top = TEX(0); + float3 bottom = TEX(1); + + float dist0 = phase; + float dist1 = 1.0 - phase; + + float3 scanline = float3(0,0,0); + + scanline += beam(top, dist0); + scanline += beam(bottom, dist1); + + return float4(_BOOST * scanline / 1.15, 1.0); + } + ENDCG + } + + Pass + { + Name "threshold" + + CGPROGRAM + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + sampler2D _MainTex; + float2 _iResolution; + + float _GLOW_WHITEPOINT; + float _GLOW_ROLLOFF; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + float4 frag(v2f IN) : SV_Target + { + float3 color = 1.15*tex2D(_MainTex,IN.uv).rgb; + float3 factor = saturate(color / _GLOW_WHITEPOINT); + return float4(pow(factor,_GLOW_ROLLOFF),1.0); + } + ENDCG + } + + Pass + { + Name "blur_horiz" + + CGPROGRAM + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + sampler2D _MainTex; + float2 _iResolution; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + #include "blur_params.cginc" + #define kernel(x) exp(-GLOW_FALLOFF * (x) * (x)) + + float4 frag(v2f IN) : SV_Target + { + float3 col = float3(0,0,0); + float dx = 4.0 / _iResolution.x; // Mipmapped + + float k_total = 0.0; + for (int i = -TAPS; i <= TAPS; i++) + { + float k = kernel(i); + k_total += k; + col += k * tex2D(_MainTex, IN.uv + float2(float(i) * dx, 0.0)).rgb; + } + return float4(col / k_total, 1.0); + } + ENDCG + } + + Pass + { + Name "blur_vert" + + CGPROGRAM + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + sampler2D _MainTex; + float2 _iResolution; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + #include "blur_params.cginc" + #define kernel(x) exp(-GLOW_FALLOFF * (x) * (x)) + + float4 frag(v2f IN) : SV_Target + { + float3 col = float3(0,0,0); + float dy = 1.0 / _iResolution.y; + + float k_total = 0.0; + for (int i = -TAPS; i <= TAPS; i++) + { + float k = kernel(i); + k_total += k; + col += k * tex2D(_MainTex, IN.uv + float2(0.0, float(i) * dy)).rgb; + } + return float4(col / k_total, 1.0); + } + ENDCG + } + + Pass + { + Name "resolve" + + CGPROGRAM + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + sampler2D _MainTex; + sampler2D _Source; + float2 _iResolution; + + float _BLOOM_STRENGTH; + float _OUTPUT_GAMMA; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + float4 frag(v2f IN) : SV_Target + { + #if 1 + float3 source = _BLOOM_STRENGTH * tex2D(_MainTex,IN.uv).rgb; + #else + float3 source = 1.15 * tex2D(_Source,IN.uv).rgb; + float3 bloom = tex2D(_MainTex,IN.uv).rgb; + source += _BLOOM_STRENGTH * bloom; + #endif + return float4(pow(saturate(source), 1.0 / _OUTPUT_GAMMA), 1.0); + } + ENDCG + } + } +} + + + diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader.meta new file mode 100644 index 0000000..4957da8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d9ec870308fa2594badb4f3036d36fd5 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc new file mode 100644 index 0000000..120c234 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc @@ -0,0 +1,4 @@ +// Higher value, more centered glow. +// Lower values might need more taps. +#define GLOW_FALLOFF 0.35 +#define TAPS 4 \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc.meta new file mode 100644 index 0000000..8d5d2cd --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/blur_params.cginc.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8e15245c3d9a7ba4ab348d97af4d5cea +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/TestFilter.cs b/AxibugEmuOnline.Client/Assets/Script/TestFilter.cs new file mode 100644 index 0000000..da04536 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/TestFilter.cs @@ -0,0 +1,50 @@ +#if UNITY_EDITOR +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.UI; + +[ExecuteInEditMode] +public class TestFilter : MonoBehaviour +{ + public Material filterMat; + public RawImage img; + public Texture2D source; + + private RenderTexture rt; + private RenderTexture rtWrap; + + private void Update() + { + if (rt == null) + { + rt = RenderTexture.GetTemporary(Screen.width, Screen.height); + rtWrap = RenderTexture.GetTemporary(Screen.width, Screen.height); + } + else if (rt.width != Screen.width || rt.height != Screen.height) + { + RenderTexture.ReleaseTemporary(rt); + RenderTexture.ReleaseTemporary(rtWrap); + + rt = RenderTexture.GetTemporary(Screen.width, Screen.height); + rtWrap = RenderTexture.GetTemporary(Screen.width, Screen.height); + } + + filterMat.SetVector("_iResolution", new Vector2(rt.width, rt.height)); + filterMat.SetTexture("_Source", source); + + CommandBuffer cmd = new CommandBuffer(); + { + cmd.Blit(source, rt); + for (int i = 0; i < filterMat.shader.passCount; i++) + { + cmd.Blit(rt, rtWrap, filterMat, i); + cmd.Blit(rtWrap, rt); + } + } + Graphics.ExecuteCommandBuffer(cmd); + //cmd.Release(); + + img.texture = rt; + } +} +#endif diff --git a/AxibugEmuOnline.Client/Assets/Script/TestFilter.cs.meta b/AxibugEmuOnline.Client/Assets/Script/TestFilter.cs.meta new file mode 100644 index 0000000..c1453a5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/TestFilter.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 40d1396d19f4da44f98dd2fcf6f0bc56 \ No newline at end of file From 37cd8b1d22828b0736ec93d8f41ad26367f02878 Mon Sep 17 00:00:00 2001 From: ALIENJACK Date: Thu, 26 Dec 2024 23:57:28 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BB=A4=E9=95=9CRetroAr?= =?UTF-8?q?chMattiasCRTGlow=EF=BC=8C=20filtereffect=E6=B4=BE=E7=94=9F?= =?UTF-8?q?=E7=B1=BB=E7=8E=B0=E5=9C=A8=E8=87=AA=E5=8A=A8=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=EF=BC=8C=20StripAttribute=E7=94=A8=E4=BA=8E=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E6=BB=A4=E9=95=9C=E4=B8=8D=E5=9C=A8=E6=9F=90=E4=BA=9B=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=87=AA=E5=8A=A8=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/UIPrefabs/OptionUI.prefab | 4 +- .../Assets/Scene/AxibugEmuOnline.Client.unity | 4 + .../Assets/Scene/TestFilter.unity | 89 +---------------- .../Script/AppMain/Filter/FilterEffect.cs | 16 +++ .../Script/AppMain/Filter/FilterManager.cs | 32 +++--- .../FixingPixelArtGrille.cs | 1 + .../AppMain/Filter/MattiasCRT/MattiasCRT.cs | 2 +- .../Filter/MattiasCRT/MattiasCRT.shader | 1 - .../RetroArch_Glow/RetroArchMattiasCRTGlow.cs | 70 +++++++++++++ .../RetroArchMattiasCRTGlow.cs.meta | 2 + .../Filter/RetroArch_Glow/RetroArch_Glow.mat | 61 ++---------- .../RetroArch_Glow/RetroArch_Glow.shader | 99 +++++++++++++++++-- .../OptionUI_ValueEditItem_FloatEdit.cs | 6 +- 13 files changed, 222 insertions(+), 165 deletions(-) create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs.meta diff --git a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/OptionUI.prefab b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/OptionUI.prefab index 93e3fe9..30f2e59 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/OptionUI.prefab +++ b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/OptionUI.prefab @@ -777,7 +777,7 @@ MonoBehaviour: m_MinWidth: -1 m_MinHeight: -1 m_PreferredWidth: -1 - m_PreferredHeight: 50 + m_PreferredHeight: 40 m_FlexibleWidth: -1 m_FlexibleHeight: -1 m_LayoutPriority: 1 @@ -1350,7 +1350,7 @@ MonoBehaviour: m_MinWidth: -1 m_MinHeight: -1 m_PreferredWidth: -1 - m_PreferredHeight: 50 + m_PreferredHeight: 40 m_FlexibleWidth: -1 m_FlexibleHeight: -1 m_LayoutPriority: 1 diff --git a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity index 1c5d6cb..74665c6 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/AxibugEmuOnline.Client.unity @@ -3037,6 +3037,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 6838719776118089301, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7707092914009063575, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} propertyPath: m_AnchorMax.y value: 0 diff --git a/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity b/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity index 4b2bf66..9b00b74 100644 --- a/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity +++ b/AxibugEmuOnline.Client/Assets/Scene/TestFilter.unity @@ -136,7 +136,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &33805170 RectTransform: m_ObjectHideFlags: 0 @@ -364,7 +364,6 @@ RectTransform: m_Children: - {fileID: 33805170} - {fileID: 1376779137} - - {fileID: 1373072004} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -372,92 +371,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} ---- !u!1 &1373072003 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1373072004} - - component: {fileID: 1373072006} - - component: {fileID: 1373072005} - m_Layer: 5 - m_Name: GameObject - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &1373072004 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1373072003} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1319295996} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 318.00003, y: 179} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1373072005 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1373072003} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e96dacbf1b116f64da658fbad66839e2, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Texture: {fileID: 0} - m_UVRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - m_EffectFactor: 1 - m_ColorFactor: 1 - m_BlurFactor: 1 - m_EffectMode: 0 - m_ColorMode: 0 - m_BlurMode: 3 - m_EffectColor: {r: 1, g: 1, b: 1, a: 1} - m_DesamplingRate: 1 - m_ReductionRate: 1 - m_FilterMode: 1 - m_EffectMaterial: {fileID: 21380876918929932, guid: 1a1a8e44196ca754a9a7b9cb80e17573, type: 2} - m_BlurIterations: 3 - m_FitToScreen: 1 - m_CaptureOnEnable: 0 ---- !u!222 &1373072006 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1373072003} - m_CullTransparentMesh: 1 --- !u!1 &1376779136 GameObject: m_ObjectHideFlags: 0 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs index e159f07..4d4c3ea 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterEffect.cs @@ -94,5 +94,21 @@ namespace AxibugEmuOnline.Client Value = overrideValue; } } + + [AttributeUsage(AttributeTargets.Class)] + internal class StripAttribute : Attribute + { + HashSet m_stripPlats; + /// + /// 指示一个滤镜是否会在指定的平台被剔除 + /// + /// 会被剔除的平台 + public StripAttribute(params RuntimePlatform[] stripPlatform) + { + m_stripPlats = new HashSet(stripPlatform); + } + + public bool NeedStrip => m_stripPlats.Contains(Application.platform); + } } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs index 5721c60..4ae1143 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FilterManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using UnityEngine; using static AxibugEmuOnline.Client.FilterEffect; @@ -20,19 +21,7 @@ namespace AxibugEmuOnline.Client public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg) { -#if UNITY_PSP2 - m_filters = new List(); - m_filterRomSetting = new FilterRomSetting(); - m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false); - return; -#endif - - m_filters = new List - { - new Filter(new FixingPixelArtGrille()), - new Filter(new LCDPostEffect()), - new Filter(new MattiasCRT()), - }; + loadFilters(); var json = PlayerPrefs.GetString(nameof(FilterRomSetting)); m_filterRomSetting = JsonUtility.FromJson(json) ?? new FilterRomSetting(); @@ -41,6 +30,23 @@ namespace AxibugEmuOnline.Client ShutDownFilter(); } + private void loadFilters() + { + m_filters = new List(); + + var effectBaseType = typeof(FilterEffect); + foreach (var type in effectBaseType.Assembly.GetTypes()) + { + if (type.IsAbstract) continue; + if (type.IsInterface) continue; + if (!effectBaseType.IsAssignableFrom(type)) continue; + var stripAtt = type.GetCustomAttribute(); + if (stripAtt != null && stripAtt.NeedStrip) continue; + var effect = Activator.CreateInstance(type) as FilterEffect; + m_filters.Add(new Filter(effect)); + } + } + private RenderTexture result = null; public Texture ExecuteFilterRender(Texture src) { diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs index 999267e..bdd2e99 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/FixingPixelArtGrille/FixingPixelArtGrille.cs @@ -2,6 +2,7 @@ using AxibugEmuOnline.Client; using UnityEngine; +[Strip(RuntimePlatform.PSP2)] public sealed class FixingPixelArtGrille : FilterEffect { public override string Name => nameof(FixingPixelArtGrille); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs index d6400f3..746acef 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.cs @@ -2,7 +2,7 @@ using AxibugEmuOnline.Client; using UnityEngine; using UnityEngine.Rendering; - + public sealed class MattiasCRT : FilterEffect { public override string Name => nameof(MattiasCRT); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader index 56ece40..7549595 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/MattiasCRT/MattiasCRT.shader @@ -17,7 +17,6 @@ Shader "Filter/MattiasCRT" #include "UnityCG.cginc" sampler2D _MainTex; - float4 _MainTex_TexelSize; float2 _iResolution; float2 curve(float2 uv) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs new file mode 100644 index 0000000..80e2750 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs @@ -0,0 +1,70 @@ +using Assets.Script.AppMain.Filter; +using AxibugEmuOnline.Client; +using UnityEngine; +using UnityEngine.Rendering; + +[Strip(RuntimePlatform.PSP2)] +public class RetroArchMattiasCRTGlow : FilterEffect +{ + public override string Name => nameof(RetroArchMattiasCRTGlow); + protected override string ShaderName => "Filter/RetroArch/MattiasCRTWithGlow"; + + [Range(0.02f, 20f)] + public FloatParameter InputGamma = new FloatParameter(11); + [Range(0.02f, 1f)] + public FloatParameter GaussianWidth = new FloatParameter(0.4f); + [Range(0.02f, 1f)] + public FloatParameter ColorBoost = new FloatParameter(0.4f); + [Range(0.02f, 1f)] + public FloatParameter GlowWhitePoint = new FloatParameter(0.4f); + [Range(0.1f, 6f)] + public FloatParameter GlowRolloff = new FloatParameter(2.2f); + [Range(0.05f, 0.8f)] + public FloatParameter GlowStrength = new FloatParameter(0.45f); + [Range(0.02f, 2.6f)] + public FloatParameter MonitorGamma = new FloatParameter(2.2f); + + int m_gamma_ID = Shader.PropertyToID("_gamma"); + int m_horiz_gauss_width_ID = Shader.PropertyToID("_horiz_gauss_width"); + int m_BOOST_ID = Shader.PropertyToID("_BOOST"); + int m_GLOW_WHITEPOINT_ID = Shader.PropertyToID("_GLOW_WHITEPOINT"); + int m_GLOW_ROLLOFF_ID = Shader.PropertyToID("_GLOW_ROLLOFF"); + int m_BLOOM_STRENGTH_ID = Shader.PropertyToID("_BLOOM_STRENGTH"); + int m_OUTPUT_GAMMA_ID = Shader.PropertyToID("_OUTPUT_GAMMA"); + + + CommandBuffer m_multipPassCmd; + int m_wrapRT; + + protected override void OnInit(Material renderMat) + { + m_multipPassCmd = new CommandBuffer(); + m_wrapRT = Shader.PropertyToID($"{Name}.WrapRT"); + } + + protected override void OnRenderer(Material renderMat, Texture src, RenderTexture result) + { + m_multipPassCmd.Clear(); + + m_multipPassCmd.GetTemporaryRT(m_wrapRT, result.width, result.height); + renderMat.SetVector("_iResolution", new Vector2(result.width, result.height)); + + renderMat.SetFloat(m_gamma_ID, InputGamma.GetValue()); + renderMat.SetFloat(m_horiz_gauss_width_ID, GaussianWidth.GetValue()); + renderMat.SetFloat(m_BOOST_ID, ColorBoost.GetValue()); + renderMat.SetFloat(m_GLOW_WHITEPOINT_ID, GlowWhitePoint.GetValue()); + renderMat.SetFloat(m_GLOW_ROLLOFF_ID, GlowRolloff.GetValue()); + renderMat.SetFloat(m_BLOOM_STRENGTH_ID, GlowStrength.GetValue()); + renderMat.SetFloat(m_OUTPUT_GAMMA_ID, MonitorGamma.GetValue()); + + m_multipPassCmd.Blit(src, result); + for (int i = 0; i < renderMat.shader.passCount; i++) + { + m_multipPassCmd.Blit(result, m_wrapRT, renderMat, i); + m_multipPassCmd.Blit(m_wrapRT, result); + } + + m_multipPassCmd.ReleaseTemporaryRT(m_wrapRT); + Graphics.ExecuteCommandBuffer(m_multipPassCmd); + } +} diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs.meta new file mode 100644 index 0000000..b1031e5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArchMattiasCRTGlow.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: fb6622dcbc754b744bb70f1655c3e526 \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat index 494c0bb..92d491c 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.mat @@ -23,64 +23,19 @@ Material: m_SavedProperties: serializedVersion: 3 m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - _MainTex: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} m_Ints: [] m_Floats: - - _BumpScale: 1 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _GlossMapScale: 1 - - _Glossiness: 0.5 - - _GlossyReflections: 1 - - _Metallic: 0 - - _Mode: 0 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _UVSec: 0 - - _ZWrite: 1 - - _gamma: 2.24 - - _horiz_gauss_width: 1.89 - m_Colors: - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _BLOOM_STRENGTH: 0.45 + - _BOOST: 0.4 + - _GLOW_ROLLOFF: 2.2 + - _GLOW_WHITEPOINT: 0.4 + - _OUTPUT_GAMMA: 2.2 + - _gamma: 11 + - _horiz_gauss_width: 0.4 + m_Colors: [] m_BuildTextureStacks: [] m_AllowLocking: 1 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader index bab00f0..0e35dd6 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Filter/RetroArch_Glow/RetroArch_Glow.shader @@ -1,13 +1,13 @@ -Shader "Filter/RetroArch/Glow" +Shader "Filter/RetroArch/MattiasCRTWithGlow" { Properties { _MainTex ("Texture", 2D) = "white" - _gamma("Input Gamma option: 2.4/2.0/2.6/0.02",float) = 2.4 - _horiz_gauss_width("Gaussian Width option: 0.5/0.4/0.6/0.02",float) = 0.5 - _BOOST("Color Boost option: 1.0/0.5/1.5/0.02",float) = 1.0 - _GLOW_WHITEPOINT("Glow Whitepoint option: 1.0/0.5/1.1/0.02",float) = 1.0 - _GLOW_ROLLOFF("Glow Rolloff option: 3.0 1.2 6.0 0.1",float) = 3.0 + _gamma("Input Gamma option: 2.4/2.0/2.6/0.02",float) = 11 + _horiz_gauss_width("Gaussian Width option: 0.5/0.4/0.6/0.02",float) = 0.4 + _BOOST("Color Boost option: 1.0/0.5/1.5/0.02",float) = 0.4 + _GLOW_WHITEPOINT("Glow Whitepoint option: 1.0/0.5/1.1/0.02",float) = 0.4 + _GLOW_ROLLOFF("Glow Rolloff option: 3.0 1.2 6.0 0.1",float) = 2.2 _BLOOM_STRENGTH("Glow Strength option: 0.45/0.0/0.8/0.05",float) = 0.45 _OUTPUT_GAMMA("Monitor Gamma option: 2.2/1.8/2.6/0.02",float) = 2.2 } @@ -42,6 +42,93 @@ } ENDCG } + + Pass + { + Name "MattiasCRT" + + CGPROGRAM + + #include "UnityCG.cginc" + #pragma vertex vert_img + #pragma fragment frag + + sampler2D _MainTex; + float2 _iResolution; + + struct v2f + { + float4 pos : POSITION; + float2 uv : TEXCOORD0; + }; + + float2 curve(float2 uv) + { + uv = (uv - 0.5) * 2.0; + uv *= 1.1; + uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0); + uv.y *= 1.0 + pow((abs(uv.x) / 4.0), 2.0); + uv = (uv / 2.0) + 0.5; + uv = uv *0.92 + 0.04; + return uv; + } + + float4 mainImage( float2 fragCoord ) + { + + float4 fragColor = float4(0,0,0,1); + + float2 q = fragCoord.xy / _iResolution.xy; + float2 uv = q; + uv = curve( uv ); + float x = sin(0.3*_Time+uv.y*21.0)*sin(0.7*_Time+uv.y*29.0)*sin(0.3+0.33*_Time+uv.y*31.0)*0.0017; + + float3 col; + col.r = tex2D(_MainTex,float2(x+uv.x+0.001,uv.y+0.001)).x+0.05; + col.g = tex2D(_MainTex,float2(x+uv.x+0.000,uv.y-0.002)).y+0.05; + col.b = tex2D(_MainTex,float2(x+uv.x-0.002,uv.y+0.000)).z+0.05; + col.r += 0.08*tex2D(_MainTex,0.75*float2(x+0.025, -0.027)+float2(uv.x+0.001,uv.y+0.001)).x; + col.b += 0.08*tex2D(_MainTex,0.75*float2(x+-0.02, -0.018)+float2(uv.x-0.002,uv.y+0.000)).z; + col.g += 0.05*tex2D(_MainTex,0.75*float2(x+-0.022, -0.02)+float2(uv.x+0.000,uv.y-0.002)).y; + + + col = clamp(col*0.6+0.4*col*col*1.0,0.0,1.0); + + float vig = (0.0 + 1.0*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y)); + col *= pow(vig,0.3); + + col *= float3(0.95,1.05,0.95); + col *= 2.8; + + float scans = clamp( 0.35+0.35*sin(3.5*_Time+uv.y*_iResolution.y*1.5), 0.0, 1.0); + + float s = pow(scans,1.7); + col = col*( 0.4+0.7*s) ; + + col *= 1.0+0.01*sin(110.0*_Time); + if (uv.x < 0.0 || uv.x > 1.0) + col *= 0.0; + if (uv.y < 0.0 || uv.y > 1.0) + col *= 0.0; + + + col*=1.0-0.65*clamp((fragCoord.x % 2.0 -1.0 )*2.0,0.0,1.0); + + float comp = smoothstep( 0.1, 0.9, sin(_Time) ); + + fragColor = float4(col,1.0); + + return fragColor; + } + + fixed4 frag(v2f i) : SV_Target + { + float2 pos = _iResolution.xy*i.uv; + fixed4 col = mainImage(pos); + return col; + } + ENDCG + } Pass { diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem_FloatEdit.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem_FloatEdit.cs index bd1a3ab..29e8477 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem_FloatEdit.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_ValueEditItem_FloatEdit.cs @@ -22,16 +22,20 @@ namespace AxibugEmuOnline.Client private void OnSliderValueChanged(float value) { txt_value.text = $"{value:.00}"; - m_valueMenu.OnValueChanged(value); + + if (!m_dataSetting) m_valueMenu.OnValueChanged(value); } + bool m_dataSetting; public void SetData(ValueSetMenu valueMenu) { + m_dataSetting = true; m_valueMenu = valueMenu; slider.minValue = (float)valueMenu.Min; slider.maxValue = (float)valueMenu.Max; slider.value = (float)valueMenu.ValueRaw; m_step = (slider.maxValue - slider.minValue) * 0.05f; + m_dataSetting = false; } public void OnLeft()