From 758be084fcc552f2f091af76269b94a15462995f Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Wed, 20 Mar 2024 05:41:37 -0700 Subject: [PATCH] clean up shader a bit --- assets/shaders/engine/editorWaveforms.frag | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/assets/shaders/engine/editorWaveforms.frag b/assets/shaders/engine/editorWaveforms.frag index 2dfe55d4..f80c7afb 100644 --- a/assets/shaders/engine/editorWaveforms.frag +++ b/assets/shaders/engine/editorWaveforms.frag @@ -3,6 +3,9 @@ // Used in charter by waveforms -lunar +const vec3 gradient1 = vec3(114./255., 81./255., 135./255); +const vec3 gradient2 = vec3(144./255., 80./255., 186./255); + uniform vec2 textureRes; uniform float pixelOffset; @@ -10,19 +13,18 @@ uniform sampler2D waveformTexture; uniform ivec2 waveformSize; float getAmplitude(vec2 pixel) { - float amplitudeRet = 0.; // look in charter for more how it works -lunar - float pixelID = floor((pixel.y+pixelOffset)/3.); - vec2 wavePixel = vec2(mod(pixelID, waveformSize.x), floor(pixelID/waveformSize.x)); + // TODO: INVESTIGATE THE 1.+ AND WHY IT WORKS (SRSLY I GOT NO CLUE) -lunar + vec2 wavePixel = vec2(int(pixelID)%waveformSize.x, 1.+floor(pixelID/waveformSize.x)); vec4 waveData = texture2D(waveformTexture, wavePixel / waveformSize); - switch (int(round(mod(wavePixel.x, 3.)))) { - case 0: amplitudeRet = waveData.r; break; - case 1: amplitudeRet = waveData.g; break; - case 2: amplitudeRet = waveData.b; break; + switch (int(wavePixel.x)%3) { + case 0: return waveData.r; break; + case 1: return waveData.g; break; + case 2: return waveData.b; break; } - return amplitudeRet; + return 0.; } bool inWaveForm(vec2 pixel, float width) { @@ -30,13 +32,6 @@ bool inWaveForm(vec2 pixel, float width) { return pixel.x > widthdiv2 && pixel.x < textureRes.x-widthdiv2; } -float getAmplitudePixel(vec2 pixel, vec2 offset) { - return getAmplitude(pixel + offset); -} - -const vec3 gradient1 = vec3(114./255., 81./255., 135./255); -const vec3 gradient2 = vec3(144./255., 80./255., 186./255); - void main() { vec2 pixel = openfl_TextureCoordv * textureRes;