𝗪𝗲𝗯𝗚𝗣𝗨: 𝟮𝟱𝟬,𝟬𝟬𝟬 𝗣𝗮𝗿𝘁𝗶𝗰𝗹𝗲𝘀 𝗢𝗻 𝗬𝗼𝘂𝗿 𝗕𝗿𝗼𝘄𝘀𝗲𝗿
This marks Day 50. It is the final day of my series where I build a new technology from scratch every day. I wanted to end with WebGPU.
I simulated 250,000 particles entirely on the GPU inside a browser.
Your CPU has a few fast cores. Your GPU has thousands of simple cores. A CPU moves particles one by one. A GPU moves thousands at the same time.
WebGPU is the modern successor to WebGL. It gives your browser access to hardware through compute shaders. These shaders allow the GPU to do math, not just draw graphics.
How it works:
• You create a device to manage the GPU. • You create a buffer to hold particle data like position and velocity. • You upload data once and keep it on the GPU. • You write a compute shader for one particle. • The GPU runs that shader on all 250,000 particles at once.
The data stays on the GPU. It moves from the compute step to the render step without returning to the CPU. This speed allows the simulation to run at 60fps.
WebGPU is the new foundation for in-browser math and local machine learning. It was the right way to end this series.
Thank you for following this journey. You can find the full archive of every project here.
Full code: https://github.com/dev48v/webgpu-from-zero
Complete post: https://dev.to/dev48v/webgpu-i-simulated-250000-particles-entirely-on-the-gpu-in-the-browser-2o0f
Optional learning community: https://dev48v.infy.uk/techfromzero.php