Skip to content

Commit

Permalink
Merge pull request #13474 from acolombier/fix/waveform-shader-support…
Browse files Browse the repository at this point in the history
…-for-new-struct

fix: support for new WaveformData struct in shaders
  • Loading branch information
ywwg authored Jul 15, 2024
2 parents 94bc909 + 717b633 commit fe878b9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions res/shaders/filteredsignal.frag
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ uniform sampler2D waveformDataTexture;

vec4 getWaveformData(float index) {
vec2 uv_data;
// The Waveform data is composed of 8 bytes per sample, (low, mid, high, all,
// stem1, stem2, stem3, stem4), see WaveformData struct. Currently, shaders
// don't support stem rendering.
index = 2 * index;

uv_data.y = floor(index / float(textureStride));
uv_data.x = floor(index - uv_data.y * float(textureStride));
// Divide again to convert to normalized UV coordinates.
Expand Down
15 changes: 13 additions & 2 deletions res/shaders/rgbsignal.frag
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ uniform sampler2D waveformDataTexture;

vec4 getWaveformData(float index) {
vec2 uv_data;
uv_data.y = splitStereoSignal ? floor(index / float(textureStride)) : max(floor(index / float(textureStride)), floor((index + 1) / float(textureStride)));
uv_data.x = splitStereoSignal ? floor(index - uv_data.y * float(textureStride)) : max(floor(index - uv_data.y * float(textureStride)), floor((index + 1) - uv_data.y * float(textureStride)));
// The Waveform data is composed of 8 bytes per sample, (low, mid, high,
// all, stem1, stem2, stem3, stem4), see WaveformData struct. Currently,
// shaders don't support stem rendering.
index = 2 * index;

uv_data.y = splitStereoSignal
? floor(index / float(textureStride))
: max(floor(index / float(textureStride)),
floor((index + 2) / float(textureStride)));
uv_data.x = splitStereoSignal
? floor(index - uv_data.y * float(textureStride))
: max(floor(index - uv_data.y * float(textureStride)),
floor((index + 2) - uv_data.y * float(textureStride)));
// Divide again to convert to normalized UV coordinates.
return texture2D(waveformDataTexture, uv_data / float(textureStride));
}
Expand Down
5 changes: 5 additions & 0 deletions res/shaders/stackedsignal.frag
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ uniform sampler2D waveformDataTexture;

vec4 getWaveformData(float index) {
vec2 uv_data;
// The Waveform data is composed of 8 bytes per sample, (low, mid, high, all,
// stem1, stem2, stem3, stem4), see WaveformData struct. Currently, shaders
// don't support stem rendering.
index = 2 * index;

uv_data.y = floor(index / float(textureStride));
uv_data.x = floor(index - uv_data.y * float(textureStride));
// Divide again to convert to normalized UV coordinates.
Expand Down

0 comments on commit fe878b9

Please sign in to comment.