From 41ca1927a02c55a698af5ab7af9783beeb7ea4d7 Mon Sep 17 00:00:00 2001 From: bottlefish <781230111@qq.com> Date: Mon, 20 Jul 2026 01:20:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(heatmap):=20=E4=BD=8E=E6=B8=A9=E6=AE=B5?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=93=9D=E8=89=B2=E5=99=AA=E7=82=B9=E5=B9=B6?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=8F=91=E7=83=AD=E8=89=B2=E5=B8=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../FixSystem/HeatMap/HeatMapController.cs | 8 ++++---- Assets/Scripts/FixSystem/HeatMap/HeatTest.shader | 16 +++++++++++----- Assets/Scripts/FixSystem/HeatMap/Test.mat | 4 ++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/FixSystem/HeatMap/HeatMapController.cs b/Assets/Scripts/FixSystem/HeatMap/HeatMapController.cs index e148f1038..c044f9899 100644 --- a/Assets/Scripts/FixSystem/HeatMap/HeatMapController.cs +++ b/Assets/Scripts/FixSystem/HeatMap/HeatMapController.cs @@ -22,8 +22,8 @@ public class HeatMapController : MonoBehaviour public Transform imageToRotate; // 需要旋转的Image [SerializeField, Min(0f)] private float fanStopDuration = 0.15f; [Header("低温背景")] - [SerializeField] private Color coldBaseColor = new Color(0.015f, 0.075f, 0.16f, 1f); - [SerializeField] private Color coldHighlightColor = new Color(0.02f, 0.27f, 0.48f, 1f); + [SerializeField] private Color coldBaseColor = new Color(0.005f, 0.02f, 0.55f, 1f); + [SerializeField] private Color coldHighlightColor = new Color(0f, 0.3f, 1f, 1f); [SerializeField, Min(0.01f)] private float coldNoiseScale = 1.8f; [SerializeField, Range(0f, 1f)] private float coldNoiseStrength = 0.45f; public Vector3 inPos; // Heatmap进入位置 @@ -244,7 +244,7 @@ public class HeatMapController : MonoBehaviour public void SetDataToMaterial() { // 逻辑温度 0~2 → shader 侧发热强度;各段端点连续,避免跨档跳变。 - // t=0 冷态压低,接近「看不见」;t=1/2 保持原有发热观感。 + // 保持原有温度映射,冷色替换只由 shader 处理。 if (tempture <= 1f) { float t = Mathf.Clamp01(tempture); @@ -256,7 +256,7 @@ public class HeatMapController : MonoBehaviour { float t = Mathf.Clamp01(tempture - 1f); uftempture = Mathf.Lerp(2.8f, 3.2f, t); - modulesTempture = Mathf.Lerp(1.6f, 2.3f, t); // 原 1.8 起点与上一段不连续 + modulesTempture = Mathf.Lerp(1.6f, 2.3f, t); backtemture = Mathf.Lerp(2.25f, 3.4f, t); } diff --git a/Assets/Scripts/FixSystem/HeatMap/HeatTest.shader b/Assets/Scripts/FixSystem/HeatMap/HeatTest.shader index dee4d0ae4..eb181a5e4 100644 --- a/Assets/Scripts/FixSystem/HeatMap/HeatTest.shader +++ b/Assets/Scripts/FixSystem/HeatMap/HeatTest.shader @@ -12,8 +12,8 @@ Shader "Unlit/HeatTest" _Speaktexture ("_Speaktexture", 2D) = "white" {} _headtexture ("_headtexture", 2D) = "white" {} _Temtupre("_Temtupre", float) = 0 // 世界空间中的中心 - _ColdBaseColor ("Cold Base Color", Color) = (0.015, 0.075, 0.16, 1) - _ColdHighlightColor ("Cold Highlight Color", Color) = (0.02, 0.27, 0.48, 1) + _ColdBaseColor ("Cold Base Color", Color) = (0.005, 0.02, 0.55, 1) + _ColdHighlightColor ("Cold Highlight Color", Color) = (0, 0.3, 1, 1) _ColdNoiseScale ("Cold Noise Scale", Float) = 1.8 _ColdNoiseStrength ("Cold Noise Strength", Range(0, 1)) = 0.45 } @@ -150,7 +150,8 @@ fixed4 frag (v2f i) : SV_Target float2 coldNoiseUV = worldPos.xy + float2(_Time.y * 0.012, -_Time.y * 0.009); float coldNoise = Unity_SimpleNoise(coldNoiseUV, _ColdNoiseScale); float coldVariation = saturate(0.18 + coldNoise * _ColdNoiseStrength); - fixed4 col = lerp(_ColdBaseColor, _ColdHighlightColor, coldVariation); + fixed4 coldColor = lerp(_ColdBaseColor, _ColdHighlightColor, coldVariation); + fixed4 col = coldColor; bool isFind = false; @@ -184,7 +185,10 @@ fixed4 frag (v2f i) : SV_Target fixed4 rampColor = tex2D(_RampTexture, float2(alpha, 0)); - col = rampColor; + // 保留原有色带映射,只把接近黑色的冷端替换为蓝色。 + float brightestChannel = max(rampColor.r, max(rampColor.g, rampColor.b)); + float blackMask = 1.0 - smoothstep(0.035, 0.12, brightestChannel); + col = lerp(rampColor, coldColor, blackMask); } } @@ -206,7 +210,9 @@ fixed4 frag (v2f i) : SV_Target alpha=backalpha; fixed4 rampColor = tex2D(_RampTexture, float2(alpha, 0)); - col = rampColor; + float brightestChannel = max(rampColor.r, max(rampColor.g, rampColor.b)); + float blackMask = 1.0 - smoothstep(0.035, 0.12, brightestChannel); + col = lerp(rampColor, coldColor, blackMask); } } diff --git a/Assets/Scripts/FixSystem/HeatMap/Test.mat b/Assets/Scripts/FixSystem/HeatMap/Test.mat index 3e29d0695..1a194eae2 100644 --- a/Assets/Scripts/FixSystem/HeatMap/Test.mat +++ b/Assets/Scripts/FixSystem/HeatMap/Test.mat @@ -128,6 +128,8 @@ Material: m_Floats: - _Alpha: 0.992 - _Boolean: 0 + - _ColdNoiseScale: 1.8 + - _ColdNoiseStrength: 0.45 - _ColorHSV_Brightness_1: 1 - _ColorHSV_Hue_1: 104 - _ColorHSV_Saturation_1: 1 @@ -158,6 +160,8 @@ Material: - _Center: {r: -3.77, g: 0.91, b: 0, a: 0} - _CenterScale: {r: 0, g: 0, b: 0, a: 0} - _CircleModuleSize: {r: 1, g: 1, b: 0, a: 0} + - _ColdBaseColor: {r: 0.005, g: 0.02, b: 0.55, a: 1} + - _ColdHighlightColor: {r: 0, g: 0.3, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1} - _ColorX: {r: 1, g: 1, b: 1, a: 1} - _Flip: {r: 1, g: 1, b: 1, a: 1}