← Blog

WebGPU Compute Shaders for Generative Art

webgpugraphicsrust

WebGPU Compute Shaders

WebGPU is the next-generation graphics API for the web. Unlike WebGL, it provides direct access to compute shaders, enabling GPU-accelerated computation beyond rendering.

Getting Started

@group(0) @binding(0) var<storage, read> input: array<f32>;
@group(0) @binding(1) var<storage, read_write> output: array<f32>;

@compute @workgroup_size(64)
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
    output[id.x] = input[id.x] * 2.0;
}

This pattern unlocks real-time particle systems, fluid simulation, and neural network inference — all in the browser.