forked from ppy/osu-resources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sh_ArgonBarPathBackground.fs
51 lines (37 loc) · 1.54 KB
/
sh_ArgonBarPathBackground.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef ARGON_BAR_PATH_BACKGROUND_FS
#define ARGON_BAR_PATH_BACKGROUND_FS
#undef HIGH_PRECISION_VERTEX
#define HIGH_PRECISION_VERTEX
#include "sh_Utils.h"
#include "sh_Masking.h"
#include "sh_TextureWrapping.h"
#include "sh_ArgonBarPathUtils.h"
layout(location = 2) in highp vec2 v_TexCoord;
layout(std140, set = 0, binding = 0) uniform m_ArgonBarPathBackgroundParameters
{
mediump vec2 size;
};
layout(location = 0) out vec4 o_Colour;
lowp vec4 bgColAt(highp float absoluteTexturePos, mediump float pathRadius)
{
highp float relativeTexturePos = clamp(absoluteTexturePos / pathRadius, 0.0, 1.5);
return mix(vec4(vec3(0.0), 0.2), vec4(vec3(1.0), 0.8), relativeTexturePos / 1.5);
}
lowp vec4 getColour(highp float absoluteTexturePos, mediump float pathRadius)
{
if (absoluteTexturePos > pathRadius - 1.0)
return mix(vec4(1.0), vec4(vec3(1.0), 0.0), absoluteTexturePos - (pathRadius - 1.0));
if (absoluteTexturePos > pathRadius - 2.0)
return mix(bgColAt(absoluteTexturePos, pathRadius), vec4(1.0), absoluteTexturePos - (pathRadius - 2.0));
return bgColAt(absoluteTexturePos, pathRadius);
}
void main(void)
{
highp vec2 resolution = v_TexRect.zw - v_TexRect.xy;
highp vec2 pixelPos = (v_TexCoord - v_TexRect.xy) / resolution;
mediump vec2 absolutePos = size * pixelPos;
const float pathRadius = 10.0;
highp float absoluteTexturePos = getBarTexturePosition(size, vec2(0.0, 1.0), pathRadius, absolutePos);
o_Colour = getRoundedColor(getColour(absoluteTexturePos, pathRadius), v_TexCoord);
}
#endif