From ea93b3b217625e5d949d005028cf71144ffa7230 Mon Sep 17 00:00:00 2001 From: ud18010 Date: Wed, 15 Jul 2026 20:27:08 +0800 Subject: [PATCH] =?UTF-8?q?XShader:=20=E8=BF=90=E8=A1=8C=E6=97=B6=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=85=89=E4=BB=85=E5=9C=A8=E5=85=A8=E5=B1=80=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E5=90=8E=E8=A6=86=E7=9B=96=20bakedGI=EF=BC=8C?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E4=BF=9D=E7=95=99=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=20SH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复编辑器预览中 XPbr/XTex/XTerrain 比 URP Lit 亮的问题: 旧写法无条件把 bakedGI 覆盖成 SampleXRuntimeAmbient,未运行 Game.cs 时 退回硬编码的高强度三色环境光(sky≈1.45),远亮于场景真实环境光探针。 现改为 _XRuntimeAmbientEnabled 开启后才覆盖,运行时行为不变。 Co-Authored-By: Claude Opus 4.8 --- Client/Assets/Game/shader/XShader/XPbr_Base.hlsl | 5 ++++- Client/Assets/Game/shader/XShader/XTerrain_Base.hlsl | 5 ++++- Client/Assets/Game/shader/XShader/XTex_Base.hlsl | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Client/Assets/Game/shader/XShader/XPbr_Base.hlsl b/Client/Assets/Game/shader/XShader/XPbr_Base.hlsl index 23592b91..1bd6adac 100644 --- a/Client/Assets/Game/shader/XShader/XPbr_Base.hlsl +++ b/Client/Assets/Game/shader/XShader/XPbr_Base.hlsl @@ -122,7 +122,10 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData #else inputData.bakedGI = SampleSH(inputData.normalWS); #endif - inputData.bakedGI = SampleXRuntimeAmbient(inputData.normalWS); + // 仅在运行时全局环境光开启后才覆盖(Game.cs 设置);否则保留场景自身 SH/光照贴图, + // 避免编辑器预览比 URP Lit 亮(旧写法无条件覆盖成硬编码的高强度三色环境光) + if (_XRuntimeAmbientEnabled > 0.5h) + inputData.bakedGI = SampleXRuntimeAmbient(inputData.normalWS); inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); diff --git a/Client/Assets/Game/shader/XShader/XTerrain_Base.hlsl b/Client/Assets/Game/shader/XShader/XTerrain_Base.hlsl index 8a83bb34..b9641edb 100644 --- a/Client/Assets/Game/shader/XShader/XTerrain_Base.hlsl +++ b/Client/Assets/Game/shader/XShader/XTerrain_Base.hlsl @@ -147,7 +147,10 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData #else inputData.bakedGI = SampleSH(inputData.normalWS); #endif - inputData.bakedGI = SampleXRuntimeAmbient(inputData.normalWS); + // 仅在运行时全局环境光开启后才覆盖(Game.cs 设置);否则保留场景自身 SH/光照贴图, + // 避免编辑器预览比 URP Lit 亮(旧写法无条件覆盖成硬编码的高强度三色环境光) + if (_XRuntimeAmbientEnabled > 0.5h) + inputData.bakedGI = SampleXRuntimeAmbient(inputData.normalWS); inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); diff --git a/Client/Assets/Game/shader/XShader/XTex_Base.hlsl b/Client/Assets/Game/shader/XShader/XTex_Base.hlsl index dbae7161..aa0cdcd0 100644 --- a/Client/Assets/Game/shader/XShader/XTex_Base.hlsl +++ b/Client/Assets/Game/shader/XShader/XTex_Base.hlsl @@ -149,7 +149,10 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData #else inputData.bakedGI = SampleSH(inputData.normalWS); #endif - inputData.bakedGI = SampleXRuntimeAmbient(inputData.normalWS); + // 仅在运行时全局环境光开启后才覆盖(Game.cs 设置);否则保留场景自身 SH/光照贴图, + // 避免编辑器预览比 URP Lit 亮(旧写法无条件覆盖成硬编码的高强度三色环境光) + if (_XRuntimeAmbientEnabled > 0.5h) + inputData.bakedGI = SampleXRuntimeAmbient(inputData.normalWS); inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);