From 70bc735fb5128744805d17c8aa0ec1b0a878ccc5 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Fri, 24 Jan 2025 15:06:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=A7=88rom=E5=A4=A7=E5=9B=BE?= =?UTF-8?q?=E8=83=8C=E6=99=AFshader=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Resources/Materials/UIBlur.mat | 42 ++++++ .../Materials/UIBlur.mat.meta} | 6 +- .../Assets/Resources/Materials/UIBlur.shader | 121 ++++++++++++++++++ .../Resources/Materials/UIBlur.shader.meta | 9 ++ .../Resources/UIPrefabs/LaunchUI.prefab | 31 +---- .../Game_NES_Template.prefab | 1 + .../Assets/Script/AppMain/UI/LaunchUI.cs | 13 +- 7 files changed, 178 insertions(+), 45 deletions(-) create mode 100644 AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.mat rename AxibugEmuOnline.Client/Assets/{Script/AppMain/UMame.meta => Resources/Materials/UIBlur.mat.meta} (52%) create mode 100644 AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader create mode 100644 AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader.meta diff --git a/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.mat b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.mat new file mode 100644 index 00000000..df54f24d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.mat @@ -0,0 +1,42 @@ +%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: UIBlur + m_Shader: {fileID: 4800000, guid: 5f3a2ea665f37834488eb2ca672f48f9, 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: + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BlurSize: 1.2 + - _Brightness: 0.37 + - _NoiseIntensity: 0 + - _Saturation: 0.77 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + m_Colors: + - _TintColor: {r: 0.31132078, g: 0.31132078, b: 0.31132078, a: 1} + m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UMame.meta b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.mat.meta similarity index 52% rename from AxibugEmuOnline.Client/Assets/Script/AppMain/UMame.meta rename to AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.mat.meta index a9b1f05c..8cbce8a3 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UMame.meta +++ b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.mat.meta @@ -1,8 +1,8 @@ fileFormatVersion: 2 -guid: ea791d3660bb49a4d94f1d824a488569 -folderAsset: yes -DefaultImporter: +guid: 560139f633c746e41b0599a5eaab7a8e +NativeFormatImporter: externalObjects: {} + mainObjectFileID: 2100000 userData: assetBundleName: assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader new file mode 100644 index 00000000..f3d6d050 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader @@ -0,0 +1,121 @@ +Shader "UI/Blur" +{ + Properties + { + [PerRendererData] _MainTex ("Main Texture", 2D) = "white" {} + _BlurSize ("Blur Size", Range(0, 5)) = 1.0 + _TintColor ("Tint Color", Color) = (1,1,1,1) + + [Header(Stencil)] + _StencilComp ("Stencil Comparison", Float) = 8 + _Stencil ("Stencil ID", Float) = 0 + _StencilOp ("Stencil Operation", Float) = 0 + } + + SubShader + { + Tags + { + "Queue"="Transparent" + "IgnoreProjector"="True" + "RenderType"="Transparent" + "PreviewType"="Plane" + "CanUseSpriteAtlas"="True" + } + + Cull Off + Lighting Off + ZWrite Off + ZTest [unity_GUIZTestMode] + Blend SrcAlpha OneMinusSrcAlpha + + Stencil + { + Ref [_Stencil] + Comp [_StencilComp] + Pass [_StencilOp] + } + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma multi_compile __ UNITY_UI_CLIP_RECT + + #include "UnityCG.cginc" + #include "UnityUI.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + float4 color : COLOR; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float4 vertex : SV_POSITION; + float4 color : COLOR; + float4 worldPosition : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _MainTex_TexelSize; + float _BlurSize; + fixed4 _TintColor; + float4 _ClipRect; + + v2f vert (appdata v) + { + v2f o; + o.worldPosition = v.vertex; + o.vertex = UnityObjectToClipPos(o.worldPosition); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + o.color = v.color * _TintColor; + + #ifdef UNITY_HALF_TEXEL_OFFSET + o.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1); + #endif + + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // 5x5高斯核权重(已归一化) + static const float weight[5][5] = { + {0.003765, 0.015019, 0.023792, 0.015019, 0.003765}, + {0.015019, 0.059912, 0.094907, 0.059912, 0.015019}, + {0.023792, 0.094907, 0.150342, 0.094907, 0.023792}, + {0.015019, 0.059912, 0.094907, 0.059912, 0.015019}, + {0.003765, 0.015019, 0.023792, 0.015019, 0.003765} + }; + + half4 color = 0; + float2 texelSize = _MainTex_TexelSize.xy * _BlurSize; + + // 二维高斯采样 + for (int x = -2; x <= 2; x++) { + for (int y = -2; y <= 2; y++) { + float2 offset = float2(x, y) * texelSize; + color += tex2D(_MainTex, i.uv + offset) * weight[x + 2][y + 2]; + } + } + + // UI颜色混合 + color *= i.color; + + // Clip Rect处理 + #ifdef UNITY_UI_CLIP_RECT + color.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect); + #endif + + return color; + } + ENDCG + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader.meta b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader.meta new file mode 100644 index 00000000..584d985e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Resources/Materials/UIBlur.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5f3a2ea665f37834488eb2ca672f48f9 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/LaunchUI.prefab b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/LaunchUI.prefab index df3da19f..a216b881 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/LaunchUI.prefab +++ b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/LaunchUI.prefab @@ -175,7 +175,6 @@ GameObject: - component: {fileID: 1749614979705703043} - component: {fileID: 2831564238218273703} - component: {fileID: 6913951815547872457} - - component: {fileID: 968819366492627815} m_Layer: 5 m_Name: RomPreview m_TagString: Untagged @@ -222,7 +221,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: m_EditorClassIdentifier: - m_Material: {fileID: 0} + m_Material: {fileID: 2100000, guid: 560139f633c746e41b0599a5eaab7a8e, type: 2} m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} @@ -252,34 +251,6 @@ CanvasGroup: m_Interactable: 1 m_BlocksRaycasts: 1 m_IgnoreParentGroups: 0 ---- !u!114 &968819366492627815 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551260616775499633} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Version: 300 - m_EffectMaterial: {fileID: 21563344409783084, guid: aee96bc531e6eba468ec405e536f515f, type: 2} - m_EffectFactor: 1 - m_ColorFactor: 1 - m_BlurFactor: 1 - m_EffectMode: 0 - m_ColorMode: 0 - m_BlurMode: 1 - m_AdvancedBlur: 0 - m_ShadowBlur: 1 - m_ShadowStyle: 0 - m_ShadowColor: {r: 0, g: 0, b: 0, a: 1} - m_EffectDistance: {x: 1, y: -1} - m_UseGraphicAlpha: 1 - m_EffectColor: {r: 1, g: 1, b: 1, a: 1} - m_AdditionalShadows: [] --- !u!1 &1639091783724093882 GameObject: m_ObjectHideFlags: 0 diff --git a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab index aa8146cd..c7a97464 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab +++ b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab @@ -476,6 +476,7 @@ MonoBehaviour: SelectScale: 1 UnSelectScale: 1 RomGroupRoot: {fileID: 3086674949377227884} + StarRom: 0 Platform: 1 SearchKey: --- !u!114 &5700455559359757662 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/LaunchUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/LaunchUI.cs index f8986988..9b6beea2 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/LaunchUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/LaunchUI.cs @@ -38,19 +38,8 @@ namespace AxibugEmuOnline.Client Instance = this; m_mainLayoutPosition = MainMenuRoot.anchoredPosition; MainMenu.ListenControlAction = true; + romPreviewWraper = new AlphaWraper(XMBCG_For_RomPreviewBigPic, RomPreviewBigPic.GetComponent(), false); - - var uiEffect = RomPreviewBigPic.GetComponent(); - if (Application.platform == RuntimePlatform.PSP2) - { - uiEffect.blurMode = BlurMode.FastBlur; - uiEffect.blurFactor = 0.6f; - } - else - { - uiEffect.blurMode = BlurMode.DetailBlur; - uiEffect.blurFactor = 0.6f; - } } private void Start()