Back to Home

Xsnow

Run it live at here.

This project was inspired by the js-snow project. One has always had the nostalgia of the little X11 program called Xsnow that came with typical Linux Desktops during 1990s. To fulfill the curiosity, we managed to find the aforementioned js-snow project which runs inside a browser and was written in pure JavaScript. Thus, one can imagine that the performance would not be at best, since the trajectory for each single piece of the snowflakes is calculated on the fly in real-time, and JavaScript is not a language designed particularly good for that.

Indeed, on a typical computer it only gets around 25fps while CPU usage is boosted to 75%. Our improvements over the project lie on two folds:

  1. The core calculations were completely rewritten in C/C++ and compiled into WebAssembly (Wasm): this will give one 30fps with only less than 5%(!) CPU usage - In fact, in our implementation JavaScript is only responsible for updating positions (via DOM manipulation, which is essentially browser-native), while all the heavy-lifting of calculating the positions is eventually done in assembly.
  2. Recall the original X11 Xsnow would pile up snowflakes at the bottom of the screen, however in js-snow this was not implemented, maybe due to performance considerations. We added the piling-up and melting-away effects, so certain amount of snowflakes first pile up when they reach the bottom of the screen, and after a while will be gone (melted). Again, the implementation of these added effects, as part of the calculation, is done in C/C++.

It can be seen that by fully taking advantage of CPU's processing power via using Wasm, we are able to greatly improve computation efficiency. We are also planning to release a version based on GPU accelerators such as WebGPU, using compute shaders for position calculations.

You can find it here.

Back to Home
Copyright (C) 2025, Silicon Pilots Ltd. All Rights Reserved.