From cd34bcb5f953697578c3b4e71088840e15159d60 Mon Sep 17 00:00:00 2001 From: Richard Van Tassel Date: Thu, 20 Feb 2025 02:03:14 -0500 Subject: [PATCH 1/3] blends color alpha into icon alpha --- OpenDreamClient/Rendering/DreamIcon.cs | 2 +- OpenDreamClient/Rendering/DreamViewOverlay.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenDreamClient/Rendering/DreamIcon.cs b/OpenDreamClient/Rendering/DreamIcon.cs index fc3be2d189..33c4f6b426 100644 --- a/OpenDreamClient/Rendering/DreamIcon.cs +++ b/OpenDreamClient/Rendering/DreamIcon.cs @@ -507,7 +507,7 @@ private IRenderTexture FullRenderTexture(DreamViewOverlay viewOverlay, DrawingHa //we can use the color matrix shader here, since we don't need to blend //also because blend mode is none, we don't need to clear var colorMatrix = iconMetaData.ColorMatrixToApply.Equals(ColorMatrix.Identity) - ? new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(iconMetaData.AlphaToApply)) + ? new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(iconMetaData.ColorToApply.A * iconMetaData.AlphaToApply)) : iconMetaData.ColorMatrixToApply; ShaderInstance colorShader = DreamViewOverlay.ColorInstance.Duplicate(); diff --git a/OpenDreamClient/Rendering/DreamViewOverlay.cs b/OpenDreamClient/Rendering/DreamViewOverlay.cs index ead729a933..ca16be8156 100644 --- a/OpenDreamClient/Rendering/DreamViewOverlay.cs +++ b/OpenDreamClient/Rendering/DreamViewOverlay.cs @@ -403,9 +403,10 @@ private void ClearRenderTarget(IRenderTexture target, DrawingHandleWorld handle, ColorMatrix colorMatrix; if (ignoreColor) colorMatrix = ColorMatrix.Identity; - else if (iconMetaData.ColorMatrixToApply.Equals(ColorMatrix.Identity)) - colorMatrix = new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(iconMetaData.AlphaToApply)); - else + else if (iconMetaData.ColorMatrixToApply.Equals(ColorMatrix.Identity)) { + float blendedAlpha = iconMetaData.ColorToApply.A * iconMetaData.AlphaToApply; + colorMatrix = new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(blendedAlpha)); + } else colorMatrix = iconMetaData.ColorMatrixToApply; // We can use no shader if everything is default From cfd88dc2f2af7c86b8aca7f634302d809ed55565 Mon Sep 17 00:00:00 2001 From: Richard Van Tassel Date: Thu, 20 Feb 2025 21:44:15 -0500 Subject: [PATCH 2/3] revert alpha blending, update alpha on color change instead --- OpenDreamClient/Rendering/DreamIcon.cs | 2 +- OpenDreamClient/Rendering/DreamViewOverlay.cs | 7 +++---- OpenDreamShared/Dream/MutableAppearance.cs | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenDreamClient/Rendering/DreamIcon.cs b/OpenDreamClient/Rendering/DreamIcon.cs index 33c4f6b426..fc3be2d189 100644 --- a/OpenDreamClient/Rendering/DreamIcon.cs +++ b/OpenDreamClient/Rendering/DreamIcon.cs @@ -507,7 +507,7 @@ private IRenderTexture FullRenderTexture(DreamViewOverlay viewOverlay, DrawingHa //we can use the color matrix shader here, since we don't need to blend //also because blend mode is none, we don't need to clear var colorMatrix = iconMetaData.ColorMatrixToApply.Equals(ColorMatrix.Identity) - ? new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(iconMetaData.ColorToApply.A * iconMetaData.AlphaToApply)) + ? new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(iconMetaData.AlphaToApply)) : iconMetaData.ColorMatrixToApply; ShaderInstance colorShader = DreamViewOverlay.ColorInstance.Duplicate(); diff --git a/OpenDreamClient/Rendering/DreamViewOverlay.cs b/OpenDreamClient/Rendering/DreamViewOverlay.cs index ca16be8156..ead729a933 100644 --- a/OpenDreamClient/Rendering/DreamViewOverlay.cs +++ b/OpenDreamClient/Rendering/DreamViewOverlay.cs @@ -403,10 +403,9 @@ private void ClearRenderTarget(IRenderTexture target, DrawingHandleWorld handle, ColorMatrix colorMatrix; if (ignoreColor) colorMatrix = ColorMatrix.Identity; - else if (iconMetaData.ColorMatrixToApply.Equals(ColorMatrix.Identity)) { - float blendedAlpha = iconMetaData.ColorToApply.A * iconMetaData.AlphaToApply; - colorMatrix = new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(blendedAlpha)); - } else + else if (iconMetaData.ColorMatrixToApply.Equals(ColorMatrix.Identity)) + colorMatrix = new ColorMatrix(iconMetaData.ColorToApply.WithAlpha(iconMetaData.AlphaToApply)); + else colorMatrix = iconMetaData.ColorMatrixToApply; // We can use no shader if everything is default diff --git a/OpenDreamShared/Dream/MutableAppearance.cs b/OpenDreamShared/Dream/MutableAppearance.cs index 76c853cb03..11893f1071 100644 --- a/OpenDreamShared/Dream/MutableAppearance.cs +++ b/OpenDreamShared/Dream/MutableAppearance.cs @@ -308,6 +308,7 @@ public void SetColor(string color) { if (!ColorHelpers.TryParseColor(color, out Color)) { Color = Color.White; } + Alpha = (byte)(Color.A * 255); } /// From b26a68fdb2004ac38d0822acf37d674d55b8d1bf Mon Sep 17 00:00:00 2001 From: Richard Van Tassel Date: Fri, 21 Feb 2025 00:46:47 -0500 Subject: [PATCH 3/3] styling --- OpenDreamShared/Dream/MutableAppearance.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenDreamShared/Dream/MutableAppearance.cs b/OpenDreamShared/Dream/MutableAppearance.cs index 11893f1071..8d011e761c 100644 --- a/OpenDreamShared/Dream/MutableAppearance.cs +++ b/OpenDreamShared/Dream/MutableAppearance.cs @@ -308,6 +308,7 @@ public void SetColor(string color) { if (!ColorHelpers.TryParseColor(color, out Color)) { Color = Color.White; } + Alpha = (byte)(Color.A * 255); }