#version 450 core #pragma include ./shared.glsl #pragma include ../misc/camera.glsl in FragmentData fragmentData; layout (location = 1) uniform vec2 uRings; layout (location = 2) uniform vec2 uMarker; layout (location = 3) uniform vec4 uValue; layout (location = 4) uniform float uProgress; layout (location = 5) uniform float uSize; out vec4 outColor; #pragma include ./shared_frag.glsl /** * Calculate the splitter animation * * @param t Animation process in range [0.0, 1.0] * @param r Radius of the current fragment * * @return The animation value of splitters */ float calcSplitterAnimation(float t, float r) { return smoothstep2( animLinear(1.1 * uRings[0], (uRings[0] - 0.05), t), animLinear(1.1 * uRings[0], uRings[0], t), animLinear(1.1 * uRings[0], uRings[1], t), animLinear(1.1 * uRings[0], (uRings[1] + 0.05), t), r); } /** * Calculate the value of a splitter * * @param pi Position of the splitter as multiple of PI / 4 * @param anim Animation value calculated by 'calcSplitterAnimation' * @param a Angle of the current fragment * @param r Radius of the current fragment * @param zoom Current zoom factor * * @return Splitter value. */ float calcSplitter(float pi, float anim, float a, float r, float zoom) { return anim * calcLine(a, pi * PI / 4.0, MARKER_STRENGTH / r / zoom, MARKER_BLUR / r / zoom); } /** * Calculate the value of a ring that represents a given ship count value * * @param pi0 Position to start the value ring at as multiple of PI / 4 * @param pi1 Position to end the value ring at as multiple of PI / 4 * @param angle Angle of the current fragment * @param t Animation process in range [0.0, 1.0] * @param anim Animation value calculated by 'calcSplitterAnimation' * @param value Actual value of the ring * @param r Radius of the current fragment * @param zoom Current zoom factor * * @return Value of the value ring */ float calcValueRing(float pi0, float pi1, float angle, float t, float anim, float value, float r, float zoom) { float x = animLinear(uRings[0], uRings[1], value); x = anim * calcLine(r, animEaseInOutQuadric(uSize, x, t), RING_STRENGTH / zoom, RING_BLUR / zoom); if (pi0 < pi1) { x *= step( pi0 * PI / 4.0, angle) * step(angle, pi1 * PI / 4.0); } else { x *= step( pi0 * PI / 4.0, angle) + step(angle, pi1 * PI / 4.0); } return x; } void main() { /* setup */ float t_opn = clamp(uProgress, 0.0, 1.0); float t_cls = clamp(uProgress - 1.0, 0.0, 1.0); float r = length(fragmentData.texCoords); float zoom = pow(length(uCamera.view[0].xyz), 0.5); float angle = calcAngle(fragmentData.texCoords, VEC_HORZ); /* marker */ float m = calcMarker(t_opn, angle, r, zoom); /* splitter */ float x = calcSplitterAnimation(t_opn, r); float s0 = 0.25 * calcSplitter( 3.0, x, angle, r, zoom); float s1 = 0.25 * calcSplitter( 1.0, x, angle, r, zoom); float s2 = 0.25 * calcSplitter(-1.0, x, angle, r, zoom); float s3 = 0.25 * calcSplitter(-3.0, x, angle, r, zoom); /* rings */ float f = calcRingsAnimation(t_opn, angle, 0.0); float t_opn_rad = clamp(2.0 * t_opn, 0.0, 1.0); float r0 = 0.25 * calcRing(t_opn_rad, f, uRings[0], r, zoom); float r1 = 0.25 * calcRing(t_opn_rad, f, uRings[1], r, zoom); float v0 = 0.75 * calcValueRing( 3.0, -3.0, angle, t_opn_rad, f, uValue[0], r, zoom); float v1 = 0.75 * calcValueRing( 1.0, 3.0, angle, t_opn_rad, f, uValue[1], r, zoom); float v2 = 0.75 * calcValueRing(-1.0, 1.0, angle, t_opn_rad, f, uValue[2], r, zoom); float v3 = 0.75 * calcValueRing(-3.0, -1.0, angle, t_opn_rad, f, uValue[3], r, zoom); /* alpha */ float a = calcAlpha(t_opn, t_cls); /* put together */ vec3 rgb = vec3(1.0); outColor = vec4(rgb, (v0 + v1 + v2 + v3 + r0 + r1 + m + s0 + s1 + s2 + s3) * a + uSize * 0.0001); }