home/ atoms/ glsl-uniform-cpu-to-gpu

GLSL uniforms pass values from the CPU to the GPU each frame

A uniform in GLSL is a variable declared outside of the shader’s main function that receives its value from the host environment (the CPU) rather than being computed on the GPU. The host updates uniforms each frame — common examples include time (elapsed seconds), resolution (canvas size in pixels), and audio analysis data. From within the shader, uniforms appear as read-only values shared across every pixel. They are the primary bridge between a live-coding environment running on the CPU and a real-time visual computed on the GPU.

Examples

In The Force, time is a built-in uniform: float color = sin(time * 4.); — no need to declare it; the host injects it. Similarly bands[0]bands[3] are audio FFT values transferred from the CPU microphone analysis to the GPU each frame.

Assessment

Explain why the keyword ‘uniform’ denotes a value the shader receives rather than computes. Then describe the data flow path from a microphone sample to a pixel color change driven by FFT.

“a uniform is a value transferred from the CPU to the GPU). One such value is `time`.”
corpus · workshop-notes-audiovisual-programming-wac-2019-charlie-robe · chunk 1