From 5377dd692625f510a846721e16e3cb8c1965b3e0 Mon Sep 17 00:00:00 2001 From: Red <96445749+TheShuEd@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:39:46 +0300 Subject: [PATCH] fix skin coloring (#1781) --- .../Humanoid/CP14ElfTonedSkinColoration.cs | 46 +++++++++++++------ .../_CP14/Species/skin_colorations.yml | 8 ++-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs b/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs index 9f4fc373b2..1b0d6ef9ab 100644 --- a/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs +++ b/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs @@ -40,36 +40,56 @@ public sealed partial class CP14ElfTonedSkinColoration : ISkinColorationStrategy return ValidElfSkinTone; } - public Color FromUnary(float t) + public Color FromUnary(float color) { - var tone = Math.Clamp(t, 0f, 100f); + var tone = Math.Clamp(color, 0f, 100f); - var startSat = 5f; - var startVal = 100f; + if (color < 50f) //Human toned Elf + { + var rangeOffset = tone - 20f; - var endSat = 30f; - var endVal = 25f; + var hue = 25f; + var sat = 20f; + var val = 100f; - var hue = 260f; - var sat = MathHelper.Lerp(startSat, endSat, tone / 100f); - var val = MathHelper.Lerp(startVal, endVal, tone / 100f); + if (rangeOffset <= 0) + { + hue += Math.Abs(rangeOffset); + } + else + { + sat += rangeOffset; + val -= rangeOffset; + } - return Color.FromHsv(new Vector4(hue / 360f, sat / 100f, val / 100f, 1.0f)); + return Color.FromHsv(new Vector4(hue / 360f, sat / 100f, val / 100f, 1.0f)); + } + else //Dark elf + { + var startSat = 5f; + var startVal = 100f; + + var endSat = 30f; + var endVal = 25f; + + var hue = 260f; + var sat = MathHelper.Lerp(startSat, endSat, tone / 100f); + var val = MathHelper.Lerp(startVal, endVal, tone / 100f); + + return Color.FromHsv(new Vector4(hue / 360f, sat / 100f, val / 100f, 1.0f)); + } } public float ToUnary(Color color) { var hsv = Color.ToHsv(color); - // Вычисляем относительное положение между светлой и тёмной точкой var hue = hsv.X * 360f; var sat = hsv.Y * 100f; var val = hsv.Z * 100f; - // Нормируем по value, потому что основной градиент идёт по яркости var progressVal = (100f - val) / (100f - 25f); - // Можно слегка учитывать hue/sat, но value остаётся главным драйвером return Math.Clamp(progressVal * 100f, 0f, 100f); } } diff --git a/Resources/Prototypes/_CP14/Species/skin_colorations.yml b/Resources/Prototypes/_CP14/Species/skin_colorations.yml index e542b07c39..bdd4ea56d4 100644 --- a/Resources/Prototypes/_CP14/Species/skin_colorations.yml +++ b/Resources/Prototypes/_CP14/Species/skin_colorations.yml @@ -1,7 +1,7 @@ - type: skinColoration id: CP14TieflingHues strategy: !type:ClampedHsvColoration - hue: [0.8, 1.05] + hue: [0.6, 1.05] saturation: [0.15, 0.8] value: [0.25, 0.55] @@ -19,6 +19,6 @@ - type: skinColoration id: CP14CarcatHues strategy: !type:ClampedHsvColoration - hue: [0.05, 0.55] - saturation: [0.15, 0.8] - value: [0.25, 0.55] \ No newline at end of file + hue: [0.05, 0.10] + saturation: [0.15, 0.35] + value: [0.25, 0.95] \ No newline at end of file