预览rom大图背景shader替换

This commit is contained in:
ALIENJACK\alien 2025-01-24 15:06:12 +08:00
parent c040594caa
commit 70bc735fb5
7 changed files with 178 additions and 45 deletions

View File

@ -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

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: ea791d3660bb49a4d94f1d824a488569
folderAsset: yes
DefaultImporter:
guid: 560139f633c746e41b0599a5eaab7a8e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5f3a2ea665f37834488eb2ca672f48f9
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -476,6 +476,7 @@ MonoBehaviour:
SelectScale: 1
UnSelectScale: 1
RomGroupRoot: {fileID: 3086674949377227884}
StarRom: 0
Platform: 1
SearchKey:
--- !u!114 &5700455559359757662

View File

@ -38,19 +38,8 @@ namespace AxibugEmuOnline.Client
Instance = this;
m_mainLayoutPosition = MainMenuRoot.anchoredPosition;
MainMenu.ListenControlAction = true;
romPreviewWraper = new AlphaWraper(XMBCG_For_RomPreviewBigPic, RomPreviewBigPic.GetComponent<CanvasGroup>(), false);
var uiEffect = RomPreviewBigPic.GetComponent<UIEffect>();
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()