XMB Shader!

This commit is contained in:
ALIENJACK\alien 2024-08-16 18:19:12 +08:00
parent 2a18dc593a
commit 3c16932e0f
5 changed files with 292 additions and 0 deletions

View File

@ -513,6 +513,22 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1639091783724093860, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
propertyPath: m_Color.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1639091783724093860, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
propertyPath: m_Color.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1639091783724093860, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
propertyPath: m_Color.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1639091783724093860, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
propertyPath: m_Material
value:
objectReference: {fileID: 2100000, guid: 32887f72045b00348847a9ba59ce050b, type: 2}
- target: {fileID: 1639091784002085428, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
propertyPath: m_Pivot.x
value: 0.5

View File

@ -0,0 +1,89 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: XMBBackGround
m_Shader: {fileID: 4800000, guid: e14054c41729e9b4cb671e3dde0e7df0, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
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}
- _PalTex:
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_Floats:
- _BumpScale: 1
- _ColorMask: 15
- _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
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0
- _UseUIAlphaClip: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 32887f72045b00348847a9ba59ce050b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,169 @@
Shader "AxibugEmuOnline/XMBBackGround"
{
Properties
{
_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
}
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;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
float3 lerp(float3 color1, float3 color2, float value)
{
return value * (color2 - color1) + color1;
}
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);
OUT.worldPosition = v.vertex;
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
OUT.color = v.color * _Color;
return OUT;
}
fixed4 frag(v2f IN) : SV_Target
{
float2 uv= IN.texcoord;
// Lerped background
float3 blue = float3(0, 0.4, 1);
float3 blue2 = float3(0, 0.7, 1);
float amount = (uv.x + uv.y) / 2.0;
float3 bg = lerp(blue2, blue, amount);
// Overlayed sine waves
float midHeight1 = 0.4;
float maxHeight1 = 0.5 + wave(0.0, 4.0, 0.02, 0.0, 0.02);
float power1 = 50.0; //Higher power means thinner line
float frequency1 = 2.0 + wave(0.0, 3.0, 0.03, 0.0, 0.02);
float speed1 = 0.4 + 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 = 0.42;
float maxHeight2 = 0.54 + wave(0.0, 3.0, 0.04, 0.0, 0.02);
float power2 = 50.0; //Higher power means thinner line
float frequency2 = 2.1 + wave(0.0, 4.0, 0.05, 0.0, 0.02);
float speed2 = 0.3 + 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;
if (uv.y < waveHeight1)
col = waveCol1 * col;
if (uv.y < waveHeight2)
col = waveCol2 * col;
// Output to screen
fixed4 fragColor = float4(col,1.0);
#ifdef UNITY_UI_CLIP_RECT
fragColor.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
#endif
#ifdef UNITY_UI_ALPHACLIP
clip (fragColor.a - 0.001);
#endif
return fragColor;
}
ENDCG
}
}
}

View File

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