ThreeKingdomsSlingshot/Assets/Resources/UI/UiGray.shader

94 lines
3.1 KiB
Plaintext

// UI 탈색(받은 칸 아이콘 · PD 2026-11-19 이벤트 화면 · 시안 dim_icon = 회색과 원색을 _Keep 만큼 섞음) — UI/Default 와 같은 입력(스프라이트 · 정점 색 · RectMask2D 자르기 · 스텐실) · 합성 = 보통 알파.
// Resources 에 두어 빌드에 항상 포함 — 코드 = EventScreen.GrayMat(Resources.Load<Shader>("UI/UiGray")) · 섞는 비율 = 화면 표 event_screen gray 줄.
Shader "TKS/UI Gray"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_Keep ("Keep Color", Range(0,1)) = 0.25
_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
}
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
{
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
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
float4 _MainTex_ST;
fixed _Keep;
v2f vert(appdata_t v)
{
v2f o;
o.worldPosition = v.vertex;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color * _Color;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 c = (tex2D(_MainTex, i.texcoord) + _TextureSampleAdd) * i.color;
fixed g = dot(c.rgb, fixed3(0.299, 0.587, 0.114));
c.rgb = lerp(fixed3(g, g, g), c.rgb, _Keep);
#ifdef UNITY_UI_CLIP_RECT
c.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
#endif
return c;
}
ENDCG
}
}
}