From 870f91495075bb900e78dda8ebb5270912ab3cb4 Mon Sep 17 00:00:00 2001 From: bottlefish <781230111@qq.com> Date: Thu, 2 Jul 2026 19:03:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(memory-shader):=20=E8=A1=A5=E9=BD=90=20UI?= =?UTF-8?q?=20Stencil=20=E5=B9=B6=E4=BF=AE=E5=A4=8D=20aspect=20=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../Shader/Shader/MemoryTuningSprite.shader | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Assets/Shader/Shader/MemoryTuningSprite.shader b/Assets/Shader/Shader/MemoryTuningSprite.shader index e14d2141d..30597a706 100644 --- a/Assets/Shader/Shader/MemoryTuningSprite.shader +++ b/Assets/Shader/Shader/MemoryTuningSprite.shader @@ -21,6 +21,13 @@ Shader "AibisDream/MemoryTuningSprite" _UVDistortFade ("UV Distort Fade", Range(0,1)) = 0 _MemoryGrayscale ("Memory Grayscale", Range(0,1)) = 0 _MemoryContrast ("Memory Contrast", Range(0,3)) = 1 + + [HideInInspector] _StencilComp ("Stencil Comparison", Float) = 8 + [HideInInspector] _Stencil ("Stencil ID", Float) = 0 + [HideInInspector] _StencilOp ("Stencil Operation", Float) = 0 + [HideInInspector] _StencilWriteMask ("Stencil Write Mask", Float) = 255 + [HideInInspector] _StencilReadMask ("Stencil Read Mask", Float) = 255 + [HideInInspector] _ColorMask ("Color Mask", Float) = 15 } SubShader @@ -37,7 +44,18 @@ Shader "AibisDream/MemoryTuningSprite" Cull Off Lighting Off ZWrite Off + ZTest [unity_GUIZTestMode] Blend SrcAlpha OneMinusSrcAlpha + ColorMask [_ColorMask] + + Stencil + { + Ref [_Stencil] + Comp [_StencilComp] + Pass [_StencilOp] + ReadMask [_StencilReadMask] + WriteMask [_StencilWriteMask] + } Pass { @@ -161,7 +179,7 @@ Shader "AibisDream/MemoryTuningSprite" half4 ChromaticSample(float2 uv, half4 source, half strength) { - float aspect = max(0.001, _MainTex_TexelSize.z / _MainTex_TexelSize.w); + float aspect = max(0.001, abs(_MainTex_TexelSize.z) / max(1.0, abs(_MainTex_TexelSize.w))); float angle = 0.496 * 6.2831853; float2 dirA = float2(cos(angle) / aspect, sin(angle)); float2 dirB = -dirA;