Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support for new WaveformData struct in shaders #13474

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading