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
52
53
54
55
56
|
#version 450
#extension GL_GOOGLE_include_directive : require
// The waveform from its columns (waveform.comp): one column per pixel, the
// band between its low and high filled, anti-aliased, at least a pixel
// thick; the RMS inside it brighter; played and unplayed in two colors,
// red while recording, green for the live microphone.
layout(location = 0) out vec4 out_color;
#include "WaveView.glsl"
layout(set = 2, binding = 0) readonly buffer Columns { vec4 columns[]; };
// Match layouts.Tint.
const uint TINT_RECORDING = 1u;
const uint TINT_LIVE = 2u;
void main() {
vec2 p = gl_FragCoord.xy;
uint x = uint(p.x);
vec4 col = columns[(x + u.scroll) % uint(u.size.x)];
if (x + u.filled < uint(u.size.x)) col.w = 0.0;
float mid = u.size.y * 0.5;
float scale = u.size.y * 0.46 * u.gain;
vec3 color = vec3(0.055, 0.06, 0.07);
if (col.w > 0.0) color = vec3(0.075, 0.08, 0.095);
// Center line.
color = mix(color, vec3(0.2, 0.22, 0.26), clamp(1.0 - abs(p.y - mid), 0.0, 1.0) * 0.6);
if (col.w > 0.0) {
float top = mid - col.y * scale - 0.5;
float bottom = mid - col.x * scale + 0.5;
float outside = max(top - p.y, p.y - bottom);
float cover = clamp(0.5 - outside, 0.0, 1.0);
float rms = col.z * scale;
float inner = clamp(rms - abs(p.y - mid) + 0.5, 0.0, 1.0);
bool played = u.playhead >= 0.0 && p.x < u.playhead;
vec3 band = played ? vec3(0.35, 0.8, 0.95) : vec3(0.45, 0.5, 0.58);
vec3 core = played ? vec3(0.7, 0.95, 1.0) : vec3(0.65, 0.7, 0.78);
if (u.tint == TINT_RECORDING) {
band = vec3(0.95, 0.35, 0.35);
core = vec3(1.0, 0.6, 0.55);
} else if (u.tint == TINT_LIVE) {
band = vec3(0.35, 0.75, 0.5);
core = vec3(0.65, 1.0, 0.75);
}
color = mix(color, mix(band, core, inner), cover);
}
// Playhead.
if (u.playhead >= 0.0) {
float d = abs(p.x - u.playhead);
color = mix(color, vec3(1.0, 0.85, 0.3), clamp(1.5 - d, 0.0, 1.0));
}
out_color = vec4(color, 1.0);
}
|