From b3c9ecd4e0d0edbb07701960c2b621675b901561 Mon Sep 17 00:00:00 2001 From: Uncomfy Date: Fri, 20 Sep 2024 07:11:14 +0300 Subject: [PATCH 1/7] Added a custom shader for beatmap backgrounds --- .../Shaders/sh_BeatmapBackground.fs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 osu.Game.Resources/Shaders/sh_BeatmapBackground.fs diff --git a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs new file mode 100644 index 00000000..e93fe73b --- /dev/null +++ b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs @@ -0,0 +1,16 @@ +#include "sh_Utils.h" +#include "sh_Masking.h" +#include "sh_TextureWrapping.h" + +layout(location = 2) in mediump vec2 v_TexCoord; + +layout(set = 0, binding = 0) uniform lowp texture2D m_Texture; +layout(set = 0, binding = 1) uniform lowp sampler m_Sampler; + +layout(location = 0) out vec4 o_Colour; + +void main(void) +{ + vec2 wrappedCoord = wrap(v_TexCoord, v_TexRect); + o_Colour = getRoundedColor(wrappedSampler(wrappedCoord, v_TexRect, m_Texture, m_Sampler, -0.9), wrappedCoord); +} From e2c52c9d9601d16a94a825214bc620ed5012cb01 Mon Sep 17 00:00:00 2001 From: Uncomfy Date: Fri, 20 Sep 2024 08:50:59 +0300 Subject: [PATCH 2/7] Made beatmap background shader accept extra params --- osu.Game.Resources/Shaders/sh_BeatmapBackground.fs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs index e93fe73b..0ea97e3e 100644 --- a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs +++ b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs @@ -7,6 +7,12 @@ layout(location = 2) in mediump vec2 v_TexCoord; layout(set = 0, binding = 0) uniform lowp texture2D m_Texture; layout(set = 0, binding = 1) uniform lowp sampler m_Sampler; +layout(std140, set = 1, binding = 0) uniform m_BeatmapBackgroundParameters +{ + lowp float m_DimLevel; + lowp float m_DimColour; +}; + layout(location = 0) out vec4 o_Colour; void main(void) From 494a3c6848834e6c7aadfbda6e4b831534ac6e2e Mon Sep 17 00:00:00 2001 From: Uncomfy Date: Fri, 20 Sep 2024 11:01:03 +0300 Subject: [PATCH 3/7] Made BeatmapBackground shader handle dimming --- osu.Game.Resources/Shaders/sh_BeatmapBackground.fs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs index 0ea97e3e..5a3522e1 100644 --- a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs +++ b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs @@ -19,4 +19,7 @@ void main(void) { vec2 wrappedCoord = wrap(v_TexCoord, v_TexRect); o_Colour = getRoundedColor(wrappedSampler(wrappedCoord, v_TexRect, m_Texture, m_Sampler, -0.9), wrappedCoord); + + vec4 dimColour = vec4(m_DimColour, m_DimColour, m_DimColour, 1.0); + o_Colour = mix(o_Colour, dimColour, m_DimLevel); } From 57f59dc47b4bca6311ca6372dc3453d5dd1def20 Mon Sep 17 00:00:00 2001 From: Uncomfy Date: Fri, 20 Sep 2024 11:32:42 +0300 Subject: [PATCH 4/7] Made BeatmapBackground shader support colour as an m_DimColour input instead of a single float --- osu.Game.Resources/Shaders/sh_BeatmapBackground.fs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs index 5a3522e1..013301ee 100644 --- a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs +++ b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs @@ -9,8 +9,8 @@ layout(set = 0, binding = 1) uniform lowp sampler m_Sampler; layout(std140, set = 1, binding = 0) uniform m_BeatmapBackgroundParameters { + lowp vec4 m_DimColour; lowp float m_DimLevel; - lowp float m_DimColour; }; layout(location = 0) out vec4 o_Colour; @@ -19,7 +19,5 @@ void main(void) { vec2 wrappedCoord = wrap(v_TexCoord, v_TexRect); o_Colour = getRoundedColor(wrappedSampler(wrappedCoord, v_TexRect, m_Texture, m_Sampler, -0.9), wrappedCoord); - - vec4 dimColour = vec4(m_DimColour, m_DimColour, m_DimColour, 1.0); - o_Colour = mix(o_Colour, dimColour, m_DimLevel); + o_Colour = mix(o_Colour, m_DimColour, m_DimLevel); } From 5495663911fba99f7e4bc3396852e04338e9960a Mon Sep 17 00:00:00 2001 From: Uncomfy Date: Sat, 21 Sep 2024 07:13:44 +0300 Subject: [PATCH 5/7] Changed BeatmapBackground class name to DimmableBeatmapBackground to avoid confusion with existing BeatmapBackground class --- ...{sh_BeatmapBackground.fs => sh_DimmableBeatmapBackground.fs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Resources/Shaders/{sh_BeatmapBackground.fs => sh_DimmableBeatmapBackground.fs} (87%) diff --git a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs b/osu.Game.Resources/Shaders/sh_DimmableBeatmapBackground.fs similarity index 87% rename from osu.Game.Resources/Shaders/sh_BeatmapBackground.fs rename to osu.Game.Resources/Shaders/sh_DimmableBeatmapBackground.fs index 013301ee..72f09db5 100644 --- a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs +++ b/osu.Game.Resources/Shaders/sh_DimmableBeatmapBackground.fs @@ -7,7 +7,7 @@ layout(location = 2) in mediump vec2 v_TexCoord; layout(set = 0, binding = 0) uniform lowp texture2D m_Texture; layout(set = 0, binding = 1) uniform lowp sampler m_Sampler; -layout(std140, set = 1, binding = 0) uniform m_BeatmapBackgroundParameters +layout(std140, set = 1, binding = 0) uniform m_DimmableBeatmapBackgroundParameters { lowp vec4 m_DimColour; lowp float m_DimLevel; From 9c2afcaf21000761b0e09bfd5035535a48139ae5 Mon Sep 17 00:00:00 2001 From: Uncomfy Date: Sun, 22 Sep 2024 06:55:58 +0300 Subject: [PATCH 6/7] Integrated DimmableBeatmapBackground into BeatmapBackground --- ...{sh_DimmableBeatmapBackground.fs => sh_BeatmapBackground.fs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Resources/Shaders/{sh_DimmableBeatmapBackground.fs => sh_BeatmapBackground.fs} (87%) diff --git a/osu.Game.Resources/Shaders/sh_DimmableBeatmapBackground.fs b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs similarity index 87% rename from osu.Game.Resources/Shaders/sh_DimmableBeatmapBackground.fs rename to osu.Game.Resources/Shaders/sh_BeatmapBackground.fs index 72f09db5..013301ee 100644 --- a/osu.Game.Resources/Shaders/sh_DimmableBeatmapBackground.fs +++ b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs @@ -7,7 +7,7 @@ layout(location = 2) in mediump vec2 v_TexCoord; layout(set = 0, binding = 0) uniform lowp texture2D m_Texture; layout(set = 0, binding = 1) uniform lowp sampler m_Sampler; -layout(std140, set = 1, binding = 0) uniform m_DimmableBeatmapBackgroundParameters +layout(std140, set = 1, binding = 0) uniform m_BeatmapBackgroundParameters { lowp vec4 m_DimColour; lowp float m_DimLevel; From d266eba4279213ce32f8bfd1e91e7eaf181ab81f Mon Sep 17 00:00:00 2001 From: Uncomfy Date: Wed, 9 Oct 2024 17:42:42 +0300 Subject: [PATCH 7/7] Changed the way DimColour is applied so it doesn't affect regular dimming that uses v_Colour --- osu.Game.Resources/Shaders/sh_BeatmapBackground.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs index 013301ee..1e0bf245 100644 --- a/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs +++ b/osu.Game.Resources/Shaders/sh_BeatmapBackground.fs @@ -18,6 +18,7 @@ layout(location = 0) out vec4 o_Colour; void main(void) { vec2 wrappedCoord = wrap(v_TexCoord, v_TexRect); - o_Colour = getRoundedColor(wrappedSampler(wrappedCoord, v_TexRect, m_Texture, m_Sampler, -0.9), wrappedCoord); - o_Colour = mix(o_Colour, m_DimColour, m_DimLevel); + vec4 texel = wrappedSampler(wrappedCoord, v_TexRect, m_Texture, m_Sampler, -0.9); + texel = mix(texel, m_DimColour, m_DimLevel); + o_Colour = getRoundedColor(texel, wrappedCoord); }