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 spinner glow resources #298

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions osu.Game.Resources/Shaders/sh_SpinnerGlow.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef SPINNER_GLOW_FS
#define SPINNER_GLOW_FS

#undef HIGH_PRECISION_VERTEX
#define HIGH_PRECISION_VERTEX

#include "sh_Utils.h"
#include "sh_Masking.h"
#include "sh_CircularProgressUtils.h"

layout(location = 2) in highp vec2 v_TexCoord;

layout(std140, set = 0, binding = 0) uniform m_ProgressGlowParameters
{
mediump float innerRadius;
mediump float progress;
highp float texelSize;
highp float glowSize;
};

layout(set = 1, binding = 0) uniform lowp texture2D m_Texture;
layout(set = 1, binding = 1) uniform lowp sampler m_Sampler;

layout(location = 0) out vec4 o_Colour;

void main(void)
{
highp vec2 resolution = v_TexRect.zw - v_TexRect.xy;

// Inflate coordinate space, so it would be (-glowSize -> 0 -> 1 -> glowSize) to preserve everything in place while inflating the draw quad
highp vec2 pixelPos = (v_TexCoord - v_TexRect.xy) / resolution * (vec2(1.0) + glowSize * 2.0) - glowSize;

highp float dst = distanceToProgress(pixelPos, progress, innerRadius, true, texelSize);
highp float progressThickness = innerRadius * 0.25;
highp float relativeTextureHeight = glowSize + progressThickness;

if (dst > relativeTextureHeight)
{
o_Colour = vec4(0.0);
return;
}

highp float textureY = 1.0 - (dst / relativeTextureHeight);
lowp vec4 texCol = texture(sampler2D(m_Texture, m_Sampler), v_TexRect.xy + vec2(0.0, textureY) * resolution, -0.9);

o_Colour = getRoundedColor(texCol, v_TexCoord);
}

#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.