Search Unity

Question Realtime Music Visualizer

Discussion in 'Shaders' started by opaqe, Jan 15, 2023.

  1. opaqe

    opaqe

    Joined:
    Nov 22, 2014
    Posts:
    8
    I'm new to shaders and I'm just sorting out the differences between unlit shaders, shader graph, and compute shader, etc. etc...

    What I'm interested in demoing is a simple spectrum visualizer. I want to map the amplitude over a 2D texture and do it realtime. Here's pseudo code for what I want to accomplish:



    // CPU
    Update:
    float[256] spectrumData = AudioListener.GetSpectrumData()
    SetShaderBuffer(spectrumData) // normalize to 0..1 values?
    RenderTexture()


    // GPU
    Shader:
    Vertex:
    color = white if texcoord.y < spectrum[texcoord.x] else black
    return color



    Help me fill in the blanks of using the right shader solution for this, and the right datatype (texture? crt? buffer?) to pass spectrum data along to the gpu.