From ed9b2923e4df8b0c6b81b60b5b78d7f67c17f9fa Mon Sep 17 00:00:00 2001 From: ksh999000 <740612340@qq.com> Date: Mon, 6 Jul 2026 16:20:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=BA=E6=99=AF=E7=89=A9?= =?UTF-8?q?=E5=93=81=E7=9A=84shader,=E6=94=B9=E4=B8=BA=E6=8E=A5=E5=8F=97?= =?UTF-8?q?=E5=85=89=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/Assets/Light/shaders/SpriteWithGroundClip.shader | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unity/Assets/Light/shaders/SpriteWithGroundClip.shader b/unity/Assets/Light/shaders/SpriteWithGroundClip.shader index cecfd55..a3616d5 100644 --- a/unity/Assets/Light/shaders/SpriteWithGroundClip.shader +++ b/unity/Assets/Light/shaders/SpriteWithGroundClip.shader @@ -35,6 +35,7 @@ Shader "Custom/SpriteWithGroundClip" Pass { Name "SpriteWithGroundClip" + Tags { "LightMode" = "UniversalForward" } HLSLPROGRAM #pragma vertex vert @@ -42,6 +43,7 @@ Shader "Custom/SpriteWithGroundClip" #pragma multi_compile_instancing #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" struct Attributes { @@ -92,6 +94,10 @@ Shader "Custom/SpriteWithGroundClip" half4 texColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv); half4 color = texColor * input.color * _Color; + // 直接接受 Directional Light 的颜色和强度(color 已包含 intensity) + Light mainLight = GetMainLight(); + color.rgb *= mainLight.color; + // 地面裁剪逻辑 if (_EnableClip > 0.5) {