From c962a9f8b2efc113db217502cafc3fe5fcfd82ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sun, 14 Aug 2022 00:01:48 +0100 Subject: [PATCH] Do a double frequency spectrum instead of a single one Just looks nicer in its current iteration --- src/music/features/visualizer/Renderer.ts | 2 +- src/music/features/visualizer/shaders/vertices.glsl | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/music/features/visualizer/Renderer.ts b/src/music/features/visualizer/Renderer.ts index 3bb5191..4287b4e 100644 --- a/src/music/features/visualizer/Renderer.ts +++ b/src/music/features/visualizer/Renderer.ts @@ -5,7 +5,7 @@ import { Cube } from "./cube"; import vertexSource from "./shaders/vertices.glsl"; import fragmentSource from "./shaders/fragments.glsl"; -const ROTATION_SPEED = 0.25; +const ROTATION_SPEED = 0.0; const BACKGROUND_COLOR = [0.0588235294118, 0.0588235294118, 0.0588235294118]; class RendererError extends Error {} diff --git a/src/music/features/visualizer/shaders/vertices.glsl b/src/music/features/visualizer/shaders/vertices.glsl index 93f65e1..92f8a63 100644 --- a/src/music/features/visualizer/shaders/vertices.glsl +++ b/src/music/features/visualizer/shaders/vertices.glsl @@ -26,11 +26,9 @@ void main() { // they should align to the X axis. float instanceX = float(gl_InstanceID * 2) * abs(aVertexPosition.x) + aVertexPosition.x; - // Since we want to scale the boxes by their frequencies, make the Y - // positions of any vertices that are > 0 (1, because this is a - // cube) = the height of the frequency. - float vertexY = - aVertexPosition.y > 0.0 ? aVertexPosition.y * aHeight : aVertexPosition.y; + // To scale the boxes by their frequencies, scale vertex Y by the + // frequency. + float vertexY = aVertexPosition.y * aHeight; gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(instanceX, vertexY, aVertexPosition.zw);