修改为单独调整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);
|
||||
|
||||
@@ -13,7 +13,9 @@ Material:
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _CASTSHADOW_ON
|
||||
- _ENABLECLIP_ON
|
||||
- _RECEIVELIGHTING_ON
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
@@ -30,9 +32,16 @@ Material:
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _CastShadow: 1
|
||||
- _ClipSoftness: 0.05
|
||||
- _EnableClip: 1
|
||||
- _GroundHeight: 0
|
||||
- _LightIntensity: 1
|
||||
- _ReceiveLighting: 1
|
||||
- _ShadowOffset: -0.1
|
||||
- _ShadowOpacity: 0.5
|
||||
m_Colors:
|
||||
- _AmbientColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ShadowColor: {r: 0, g: 0, b: 0, a: 0.5}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
@@ -371,7 +371,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
darknessMaterial: {fileID: 2100000, guid: 6dd18d2379aff3040813ab8005b1898a, type: 2}
|
||||
debugShowAll: 0
|
||||
debugShowAll: 1
|
||||
minBrightness: 0
|
||||
darknessColor: {r: 0.01, g: 0.01, b: 0.02, a: 1}
|
||||
lightSoftness: 1
|
||||
|
||||
@@ -30,10 +30,10 @@ EditorUserSettings:
|
||||
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-8:
|
||||
value: 5a55515156575a0b0f56592346260f444f16197c7e7f24697d2a4a32b1b0353e
|
||||
value: 0209025f575750595c57092149765d444e4e49727e7c7068757b1c65b6e36c3b
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-9:
|
||||
value: 0209025f575750595c57092149765d444e4e49727e7c7068757b1c65b6e36c3b
|
||||
value: 5a55515156575a0b0f56592346260f444f16197c7e7f24697d2a4a32b1b0353e
|
||||
flags: 0
|
||||
UnityEditor.ShaderGraph.Blackboard:
|
||||
value: 18135939215a0a5004000b0e15254b524c030a3f2964643d120d1230e9e93a3fd6e826abbd2e2d293c4ead313b08042de6030a0afa240c0d020be94c4ba75e435d8715fa32c70d15d11612dacc11fee5d3c5d1fe9ab1bf968e93e2ffcbc3e7e2f0b3ffe0e8b0be9af8ffaeffff8e85dd8390e3949c8899daa7
|
||||
|
||||
Reference in New Issue
Block a user