修改为单独调整shader
This commit is contained in:
@@ -31,7 +31,7 @@ Material:
|
||||
- _EchoRadius: 39.41617
|
||||
- _EchoWidth: 2.5
|
||||
- _LightSoftness: 1
|
||||
- _MinBrightness: 0
|
||||
- _MinBrightness: 1
|
||||
m_Colors:
|
||||
- _DarknessColor: {r: 0.01, g: 0.01, b: 0.02, a: 1}
|
||||
- _EchoCenter: {r: -2.4399998, g: -1.5000057, b: 0, a: 0}
|
||||
|
||||
@@ -18,6 +18,11 @@ Shader "Custom/SpriteWithGroundClip"
|
||||
|
||||
// 颜色
|
||||
_Color ("颜色", Color) = (1, 1, 1, 1)
|
||||
|
||||
// 光照设置
|
||||
_LightIntensity ("光照强度", Range(0, 2)) = 1.0
|
||||
_AmbientColor ("环境光颜色", Color) = (0.3, 0.3, 0.3, 1.0)
|
||||
[MaterialToggle] _ReceiveLighting ("接受光照", Float) = 1.0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
@@ -68,6 +73,9 @@ Shader "Custom/SpriteWithGroundClip"
|
||||
float _GroundHeight;
|
||||
float _EnableClip;
|
||||
float _ClipSoftness;
|
||||
float _LightIntensity;
|
||||
float4 _AmbientColor;
|
||||
float _ReceiveLighting;
|
||||
CBUFFER_END
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
@@ -94,9 +102,19 @@ 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 (_ReceiveLighting > 0.5)
|
||||
{
|
||||
// 获取主光源(颜色已包含强度)
|
||||
Light mainLight = GetMainLight();
|
||||
half3 lightColor = mainLight.color;
|
||||
|
||||
// Sprite无网格法线,直接用光源颜色作为受光亮度
|
||||
// 环境光提供基础亮度,漫反射光叠加方向光颜色
|
||||
half3 ambient = _AmbientColor.rgb;
|
||||
half3 diffuse = lightColor * _LightIntensity;
|
||||
color.rgb *= (ambient + diffuse);
|
||||
}
|
||||
|
||||
// 地面裁剪逻辑
|
||||
if (_EnableClip > 0.5)
|
||||
@@ -168,6 +186,9 @@ Shader "Custom/SpriteWithGroundClip"
|
||||
float _ShadowOpacity;
|
||||
float _ShadowOffset;
|
||||
float4 _ShadowColor;
|
||||
float _LightIntensity;
|
||||
float4 _AmbientColor;
|
||||
float _ReceiveLighting;
|
||||
CBUFFER_END
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
|
||||
@@ -192,7 +192,7 @@ Shader "IndianOcean/WaterReflection"
|
||||
|
||||
// UI 裁剪矩形裁剪
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
float2 clipPos = positionCS.xy;
|
||||
float2 clipPos = input.positionCS.xy;
|
||||
float clip = 1.0;
|
||||
clip *= step(0.0, clipPos.x - _ClipRect.x);
|
||||
clip *= step(0.0, clipPos.y - _ClipRect.y);
|
||||
|
||||
Reference in New Issue
Block a user