移除部分XMB背景shader继承自ugui的特性,减少开销

This commit is contained in:
ALIENJACK\alien 2025-01-07 17:21:02 +08:00
parent c0ae876581
commit 67c0a47fe3
4 changed files with 3 additions and 255 deletions

View File

@ -2104,7 +2104,7 @@ PrefabInstance:
- target: {fileID: 2619187604372594158, guid: 98ac562d730eabc42b9a3b12c715d114, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 8b2d1bdf739173c40bb205540b308d02, type: 3}
objectReference: {fileID: 8228730565043098574, guid: d518d00d4940e854bbe45d9ef891401a, type: 3}
- target: {fileID: 3189920797946144379, guid: 98ac562d730eabc42b9a3b12c715d114, type: 3}
propertyPath: m_Name
value: "\u753B\u9762\u6BD4\u4F8B"
@ -2172,7 +2172,7 @@ PrefabInstance:
- target: {fileID: 6771349210554360888, guid: 98ac562d730eabc42b9a3b12c715d114, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: 8b2d1bdf739173c40bb205540b308d02, type: 3}
objectReference: {fileID: 8228730565043098574, guid: d518d00d4940e854bbe45d9ef891401a, type: 3}
- target: {fileID: 8126322204359135913, guid: 98ac562d730eabc42b9a3b12c715d114, type: 3}
propertyPath: m_AnchorMax.y
value: 0

View File

@ -5,12 +5,6 @@
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
@ -45,15 +39,6 @@
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
@ -72,9 +57,6 @@
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
struct appdata_t
{
float4 vertex : POSITION;
@ -94,12 +76,7 @@
};
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
sampler2D _MainTex;
float4 _MainTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
float wave(float x, float frequency, float speed, float midHeight, float maxHeight)
{
@ -128,10 +105,7 @@
float2 pixelSize = vPosition.w;
pixelSize /= float2(1, 1) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
float2 maskUV = (v.vertex.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
OUT.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
OUT.mask = float4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
OUT.texcoord = v.texcoord.xy;
OUT.color = v.color * _Color;
return OUT;
@ -187,15 +161,6 @@
// Output to screen
fixed4 fragColor = float4(col,1.0)*IN.color;
#ifdef UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
fragColor.a *= m.x * m.y;
#endif
#ifdef UNITY_UI_ALPHACLIP
clip (fragColor.a - 0.001);
#endif
return fragColor;
}

View File

@ -1,207 +0,0 @@
Shader "AxibugEmuOnline/XMBBackGroundPreview"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
[Space(10)]
_Color1("Color1",Color) = (0,0.4,1,1)
_Color2("Color2",Color) = (0,0.7,1,1)
[Header(Wave1)]
_MidHeight1("MidHeight",Float) = 0.4
_MaxHeight1("MaxHeigh",Float) = 0.5
_Power1("Power",Float)=50.0
_Frequency1("Frequency",Float)=2.0
_Speed1("Speed",Float)=0.4
[Header(Wave2)]
_MidHeight2("MidHeight",Float) = 0.42
_MaxHeight2("MaxHeigh",Float) = 0.54
_Power2("Power",Float)=50.0
_Frequency2("Frequency",Float)=2.1
_Speed2("Speed",Float)=0.3
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
Name "Default"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 mask : TEXCOORD2;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
sampler2D _MainTex;
float4 _MainTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
float wave(float x, float frequency, float speed, float midHeight, float maxHeight)
{
return (sin(frequency * (x + speed * (((1. - (pow(cos(0.002 * (_Time.y + 400.)), 2.) + 1.) / 2.) + .1) * 2048.))) * (maxHeight - midHeight)) + midHeight;
}
float percentHigh(float currentY, float waveHeight, float maxHeight, float power)
{
float percentWave = max(waveHeight - currentY, 0.0) / maxHeight;
return pow(1.0 - percentWave, power);
}
float waveColor(float2 uv, float waveHeight, float maxHeight, float frequency, float power)
{
float percentWave = percentHigh(uv.y, waveHeight, maxHeight, power);
return clamp(percentWave + 0.8, 0.0, 1.0);
}
v2f vert(appdata_t v)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
float4 vPosition = UnityObjectToClipPos(v.vertex);
OUT.worldPosition = v.vertex;
OUT.vertex = vPosition;
float2 pixelSize = vPosition.w;
pixelSize /= float2(1, 1) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
float2 maskUV = (v.vertex.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
OUT.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
OUT.mask = float4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
OUT.color = v.color * _Color;
return OUT;
}
float3 _Color1;
float3 _Color2;
float _MidHeight1;
float _MaxHeight1;
float _Power1;
float _Frequency1;
float _Speed1;
float _MidHeight2;
float _MaxHeight2;
float _Power2;
float _Frequency2;
float _Speed2;
fixed4 frag(v2f IN) : SV_Target
{
float2 uv= IN.texcoord;
// Lerped background
float amount = (uv.x + uv.y) / 2.0;
float3 bg = lerp(_Color2, _Color1, amount);
// Overlayed sine waves
float maxHeight1 = _MaxHeight1 + wave(0, 4.0,0.02, 0.0, 0.02);
float power1 = _Power1; //Higher power means thinner line
float frequency1 = _Frequency1 + wave(0.0, 3.0, 0.03, 0.0, 0.02);
float speed1 = _Speed1 + wave(0.0, 2.2, 0.04, 0.0, 0.01);
float waveHeight1 = wave(uv.x, frequency1, speed1, _MidHeight1, maxHeight1);
float waveCol1 = waveColor(uv, waveHeight1, maxHeight1, frequency1, power1);
float midHeight2 = _MidHeight2;
float maxHeight2 = _MaxHeight2 + wave(0.0, 3.0, 0.04, 0.0, 0.02);
float power2 = _Power2; //Higher power means thinner line
float frequency2 = _Frequency2 + wave(0.0, 4.0, 0.05, 0.0, 0.02);
float speed2 = _Speed2 + wave(0.0, 2.0, 0.02, 0.0, 0.01);
float waveHeight2 = wave(uv.x, frequency2, speed2, midHeight2, maxHeight2);
float waveCol2 = waveColor(uv, waveHeight2, maxHeight2, frequency2, power2);
float3 col = bg;
float3 waveCol1_temp=col/waveCol1;
col = lerp(col,waveCol1_temp, step(uv.y, waveHeight1));
float3 waveCol2_temp=col/waveCol2;
col = lerp(col,waveCol2_temp, step(uv.y, waveHeight2));
// Output to screen
fixed4 fragColor = float4(col,1.0)*IN.color;
#ifdef UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
fragColor.a *= m.x * m.y;
#endif
#ifdef UNITY_UI_ALPHACLIP
clip (fragColor.a - 0.001);
#endif
return fragColor;
}
ENDCG
}
}
}

View File

@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 424d88aff12857f4aab1911fdb6e02e9
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant: