|
- #version 450 core
-
- #pragma include ./shared.glsl
- #pragma include ../../misc/camera.glsl
-
- in FragmentData fragmentData;
-
- uniform vec2 uRings;
- uniform vec2 uMarker;
- uniform float uProgress;
- uniform float uSize;
- uniform float uValue;
-
- out vec4 outColor;
-
- const float RING_STRENGTH = 0.0000;
- const float RING_BLUR = 0.0020;
- const float MARKER_STRENGTH = 0.0000;
- const float MARKER_BLUR = 0.0020;
- const vec2 VEC_HORZ = vec2(1.0, 0.0);
- const float PI = 3.1415926535897932384626433832795;
-
- float smoothstep2(float b0, float b1, float b2, float b3, float v) {
- return smoothstep(b0, b1, v) * (1.0 - smoothstep(b2, b3, v));
- }
-
- float calcLine(float actual, float expected, float strength, float blur)
- {
- return smoothstep2(
- expected - strength - blur,
- expected - strength,
- expected + strength,
- expected + strength + blur,
- actual);
- }
-
- float calcAngle(vec2 v1, vec2 v2)
- {
- v1 = -v1;
- return -atan(
- v1.x * v2.y - v1.y * v2.x,
- v1.x * v2.x + v1.y * v2.y);
- }
-
- float random(float seed) {
- return fract(sin(dot(vec4(seed), vec4(12.9898, 78.233, 45.164, 53.1324))) * 43758.5453);
- }
-
- float animate(float v0, float v1, float t) {
- float x = t * t * (3.0 - 2.0 * t);
-
- return v0 + x * (v1 - v0);
- }
-
- void main() {
- float ts = clamp(uProgress, 0.0, 1.0);
- float te = 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 = calcAngle(uMarker, VEC_HORZ);
- m = calcLine(angle, m, MARKER_STRENGTH / r / zoom, MARKER_BLUR / r / zoom);
- m *= smoothstep2(
- ts * (uRings[0] - 0.25),
- ts * uRings[0],
- ts * uRings[1],
- ts * (uRings[1] + 0.10),
- r);
- m *= 0.75;
-
- /* rings */
- float f = angle / PI + 1.0;
- f = f * 2.0;
- f = fract(f + 0.5);
- f = smoothstep2(
- 0.0 - (ts - 0.5),
- 0.2 - (ts - 0.5),
- 0.8 + (ts - 0.5),
- 1.0 + (ts - 0.5),
- f);
-
- float r0 = 0.25 * f * calcLine(r, animate(uSize, uRings[0], ts), RING_STRENGTH / zoom, RING_BLUR / zoom);
- float r1 = 0.25 * f * calcLine(r, animate(uSize, uRings[1], ts), RING_STRENGTH / zoom, RING_BLUR / zoom);
- float v = 0.75 * f * calcLine(r, animate(uSize, uValue, ts), RING_STRENGTH / zoom, RING_BLUR / zoom);
-
- /* alpha */
- float as = step(1.0 - ts, random(uProgress));
- float ae = (1.0 - te) * step(te, random(uProgress));
- float a = as * ae;
-
- /* put together */
- vec3 rgb = vec3(1.0);
- outColor = vec4(rgb, (v + r0 + r1 + m) * a + uSize * 0.0001);
- }
|