Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a custom shader for BeatmapBackground to handle background dim colour changes #344

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
24 changes: 24 additions & 0 deletions osu.Game.Resources/Shaders/sh_BeatmapBackground.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#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(std140, set = 1, binding = 0) uniform m_BeatmapBackgroundParameters
{
lowp vec4 m_DimColour;
lowp float m_DimLevel;
};

layout(location = 0) out vec4 o_Colour;

void main(void)
{
vec2 wrappedCoord = wrap(v_TexCoord, v_TexRect);
vec4 texel = wrappedSampler(wrappedCoord, v_TexRect, m_Texture, m_Sampler, -0.9);
texel = mix(texel, m_DimColour, m_DimLevel);
o_Colour = getRoundedColor(texel, wrappedCoord);
}