This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
LEFTONE/core/loshader/hud_bar.vshader

57 lines
1.3 KiB
Plaintext
Raw Normal View History

layout (location = 0) in vec2 i_pos;
layout (location = 1) in vec2 i_size;
layout (location = 2) in vec4 i_bgcolor;
layout (location = 3) in vec4 i_fgcolor;
layout (location = 4) in float i_value;
layout (location = 5) in float i_prev_value;
out vec2 v_pos;
out vec2 v_size;
out vec2 v_aa;
out vec2 v_dp;
out vec4 v_color;
void main() {
const vec2[] verts = vec2[](
vec2(-1., 1.),
vec2(-1., -1.),
vec2( 1., -1.),
vec2(-1., 1.),
vec2( 1., -1.),
vec2( 1., 1.)
);
float scale = (uni.cam * vec4(1., 0., 0., 0.)).x;
scale = pow(1.2, scale-1.);
v_pos = i_pos;
v_size = i_size;
int id = 0;
if (gl_VertexID < 6) {
id = gl_VertexID;
v_size += vec2(2.)/uni.resolution;
v_color = i_bgcolor;
} else if (gl_VertexID < 12) {
id = gl_VertexID - 6;
v_pos.x -= v_size.x*(1.-i_prev_value);
v_size.x *= i_prev_value;
v_color = mix(i_bgcolor, i_fgcolor, .5);
} else {
id = gl_VertexID - 12;
v_pos.x -= v_size.x*(1.-i_value);
v_size.x *= i_value;
v_color = i_fgcolor;
}
v_pos *= scale;
v_size *= scale;
v_size = abs(v_size);
v_aa = uni.aa / v_size;
v_dp = verts[id]*1.5*v_size + v_pos;
v_dp /= pow(length(v_dp), .1);
gl_Position = vec4(v_dp, 0., 1.);
}