ToolsMiddleweight
WebGPU
The newer, faster browser graphics API.
The newer, faster graphics API in browsers. It can run simulations on the graphics card, so a million particles at 60 fps becomes normal. Browser support is still uneven, so a demo usually needs a fallback for older browsers.
- Breaks when
- uneven browser support; needs a WebGL fallback pathmodels mix WebGL and WebGPU APIs
- Also called
- WebGPURenderer, wgpu, navigator.gpu
Prompts
Million-particle field, Three.js
Three.js WebGPURenderer with TSL. A compute node updates 1,000,000 particle positions in a storage buffer each frame: curl-noise advection, damping 0.98, respawn on a sphere when |p| > 3. Render as sprite nodes sized by speed, additive blending. Detect navigator.gpu; when absent, fall back to WebGLRenderer with 50,000 CPU particles and the same look. Show fps and the particle count in a corner.
Raw compute + render
Plain WebGPU, no library. One compute pipeline (workgroup size 64) runs a Gray–Scott reaction-diffusion (f = 0.037, k = 0.06) on a 512² storage texture, ping-ponged. One render pipeline draws it full-screen through a two-color ramp. Async init that requests the adapter and device, prints the adapter limits, and shows a plain message when navigator.gpu is undefined.
GPU-sorted splats
A WebGPU viewer for a .splat file: a compute pass writes view-space depth and radix-sorts the indices, then instanced quads draw the gaussians back to front with correct alpha. State how many passes the sort takes and keep it under 4 ms for one million splats.
Related
Resources · 3
- three.js example: WebGPU compute particlesA million particles via TSL compute; the WebGPU starting point.mrdoobsite · code · demoAug 8, 2026
- WebGPU FundamentalsThe WGSL tutorial worth prompting from.greggmansite · code · demoJul 20, 2026
- Three.js Shading Language (TSL)Write once, compiles to WGSL or GLSL.mrdoobGitHub · codeMar 8, 2026