A GPU-driven audio visualiser that generates a dynamic grid of cubes whose height responds to real-time audio spectrum data. The geometry is entirely computed on the GPU using a compute shader with Perlin noise modulation.
Tutorial: Watch on YouTube (German)
Build a fully GPU-driven audio visualisation pipeline where no geometry exists on the CPU. A compute shader generates an entire cube grid per frame, with cube heights driven by FFT frequency band data and Perlin noise. The project demonstrates the complete path from audio input through spectral analysis to procedural mesh output — all without GameObject transforms or CPU-side vertex buffers.
1. Audio Spectrum Analysis. Extract frequency data from the audio source via FFT, group it into perceptually meaningful bands, and normalise for visual mapping.
2. Band Buffering. Smooth raw frequency values through a decay buffer to prevent harsh visual flickering between frames.
3. GPU Cube Generation. Dispatch a compute shader that generates the full grid geometry (vertices, normals, indices) directly into GPU buffers, modulated by the buffered audio amplitude and animated Perlin noise.
Unity's AudioSource.GetSpectrumData provides 512 raw FFT samples using a Blackman-Harris window. These samples are grouped into 8 frequency bands with exponentially increasing bin sizes:
For each band
where
Raw frequency values are smoothed through a decay buffer. For each band
Bands are then normalised against their observed peak to produce values in
The global amplitude buffer aggregates all bands:
A compute shader dispatched with [numthreads(8, 8, 1)] generates a
Perlin noise is evaluated per cube using a time-evolving seed:
The cube height
Each cube is defined by 8 vertices and 36 indices (12 triangles), written directly into RWStructuredBuffer objects.
| Buffer | Content | Stride |
|---|---|---|
| Vertex Buffer | float3 position + float3 normal |
24 bytes per vertex |
| Index Buffer | Triangle indices | 4 bytes per index |
| Parameter | Location | Description | Default |
|---|---|---|---|
width / length |
CubeGenerator | Grid dimensions | 10 × 10 |
gap |
CubeGenerator | Spacing between cubes | 0.5 |
seedChangeSpeed |
CubeGenerator | Noise animation speed | 1.0 |
amplitude |
CubeGenerator | Base amplitude scalar | — |
bandCount |
AudioData | Number of frequency bands | 8 |
git clone https://github.com/maybebool/Unity-AudioReactiveGrid.git- Open the project in Unity 2022.3+.
- Attach an
AudioSourcewith a music clip to the scene. - Press Play — the grid generates and responds to the audio in real time.
Prerequisites: Unity 2022.3+, GPU with Compute Shader support.
| Category | Technology |
|---|---|
| Engine | Unity 2022.3+ |
| Language | C# — FFT analysis, buffer smoothing, CPU-GPU bridge |
| GPU Compute | HLSL Compute Shader — procedural cube generation with Perlin noise |
| Rendering | Graphics.DrawProceduralIndirect, RWStructuredBuffer |
| Audio | Unity AudioSource FFT with Blackman-Harris windowing |
The current system generates a uniform cube grid modulated by a single amplitude value. Possible extensions include:
- Per-band grid regions where different frequency bands drive different sections of the grid
- Alternative geometry (spheres, hexagonal prisms) selectable at runtime
- Colour mapping driven by frequency content (low = warm, high = cool)
- Mesh deformation instead of height scaling for smoother organic surfaces
- VR placement for immersive audio-visual environments
- Multiple audio source support with blended influence zones