Recreating macOS’s Drift Screensaver with Rust and WASM
github.com
github.com
I always assumed the screensavers that ship with the Mac are carefully designed not to unnecessarily drain the battery, but I realised just now that’s just an assumption.
It's a fluid simulation. Compute shaders, compute shaders, compute shaders.
IMO the best balance would be maxing out the AVX pipeline but keeping the CPU at base clock, and then leave the rendering/framebuffer manipulation to the GPU. I suspect that running both the simulation and 5k/2k displays simultaneously is too much for the GPU to handle.
I think it did on the Mac too - but don’t quote me…
normal | running screensaver in browser
CPU: 5% | 15%
GPU: 10% | 45%So either your screen was always on, or you printed moving pattern to avoid burning the phosphor.
If the monitor is going to be on anyway, why wouldn't people want to display something interesting on it?
b) Fun
Out of curiosity, why Rust? Not saying anything against it, just looking to understand your take on it.
1. It absolutely had to run in the browser. 2. I wanted the option of shipping native binaries later on, e.g. screensavers
This narrows the choice to something that can compile to WASM and has bindings for WebGL/OpenGL. Rust has substantial support for these technologies, there's an active graphics community, and, personally, it felt approachable for someone without experience with C/C++.
Also, I write Haskell/Elm for a living. I don't need much convincing to pick up another typed, memory-safe language.
1) Colors are set based on desktop wallpaper chosen by the user automatically
2) The little lines never cross at more than slightly more than parallel in the real one, but they sometimes do here
Often Users would press the power button, when the screen was blank, even if the PC was on. Boot time was longer than two minutes and the filesystems generally didn't have journaling and were prone to corruption, when rebooted that way.