Exploring the Physics of the Universe with Vanilla JavaScript and GPU Computing
🌌 Reality: Exploring the Physics of the Universe with Vanilla JavaScript and GPU Computing
What happens when curiosity about the universe meets software engineering?
I've been working on Reality, an open-source project that brings together interactive physics simulations, GPU computing and scientific models in a browser, using WebGL2 and vanilla JavaScript, without external dependencies.
🔗 GitHub repository: https://github.com/davvoz/reality
The idea is simple: make complex physical systems interactive, allowing you to explore their behaviour, adjust parameters and observe the results in real time.
🔬 Eight simulations, eight different perspectives
Reality currently includes eight independent simulation stages, each built around a different mathematical or physical model.
🌌 Quantum Field explores the Klein–Gordon equation in an expanding Friedmann–Robertson–Walker spacetime, connecting field dynamics with the primordial spectrum of cosmological perturbations.
⚛️ Quark Confinement models the Cornell potential and the running strong coupling, exploring aspects of the interaction between quarks.
🌀 Atomic Orbital visualizes analytical solutions for the hydrogen atom, bringing quantum orbitals into a three-dimensional rendering environment.
🌠 Cosmic Structure implements direct-summation N-body dynamics, gravitational softening and cosmological expansion through the Friedmann equation.
🧬 Molecular Assembly combines Lennard-Jones and Morse potentials with partial charges derived from electronegativity.
🧪 Prebiotic Chemistry uses Gray–Scott reaction-diffusion equations to generate Turing patterns, showing how complex structures can emerge from relatively simple local interactions.
🔬 Protocell explores active matter and non-reciprocal interactions through particle dynamics, Newtonian motion and viscous drag.
🧩 Lenia implements a continuous cellular automaton with a ring-shaped kernel and neighbourhood convolution, exploring the fascinating territory between mathematics, emergent behaviour and artificial life.
These are different models with different assumptions and limitations, but together they create a small interactive laboratory for exploring phenomena across several scales, from quantum systems to cosmology and self-organizing patterns.
⚙️ The engineering behind the simulations
One of the most interesting parts of this project is the architecture.
The simulations use GPU-based computation through WebGL2 fragment shaders. State data is stored in floating-point textures, and ping-pong buffers allow each simulation step to read the current state while writing the next one.
This approach makes it possible to perform large numbers of parallel calculations directly on the graphics hardware, rather than relying entirely on JavaScript loops running on the CPU.
The application is also organized into independent stages, supported by a reusable engine with a simulation clock, event bus, GPU resource management and a registry for the available models.
Adding a new simulation follows a defined contract: implement the stage lifecycle, register the class, and integrate it into the existing system without having to rewrite the entire engine.
There are also development tools for checking JavaScript modules and their relative imports, plus an automated browser smoke test designed to visit all eight stages and detect console errors.
The project uses established reference data, including CODATA 2018 physical constants, Planck 2018 cosmological parameters and PDG 2024 Standard Model data.
🛠️ Open source, browser-based and dependency-free
Reality is written in vanilla JavaScript and uses WebGL2 for rendering and computation. It requires a compatible browser with floating-point render-target support, and Node.js 22 or newer for its development tools.
There are no npm runtime dependencies.
You can clone the repository, start the local development server and explore the implementation yourself. The project is open for inspection, experimentation, improvements and contributions.
🚀 Why I built it
I enjoy working at the intersection of software architecture, mathematics, science and experimentation. For me, a project like this is an opportunity to turn abstract equations into something visible and interactive, while also building a reusable software engine rather than a collection of disconnected visual demos.
The interesting challenge is making the mathematical model, the GPU implementation and the application architecture work together coherently.
Reality is an ongoing exploration, and there is plenty of room to expand its simulations, improve its visualizations and investigate more complex systems.
If you're interested in JavaScript, WebGL2, GPU computing, physics simulations or emergent behaviour, take a look at the repository and let me know what you think.
What would you simulate next: black holes, fluid dynamics, neural systems, or something even more unusual? 🌌
🧪 Try Reality in Your Browser
You don't need to download the source code to explore the simulations. Reality is available as an interactive web experience, where you can experiment with its physics models directly in your browser.
🌐 Live demo: https://davvoz.github.io/reality/
💻 Source code on GitHub: https://github.com/davvoz/reality
The project combines scientific concepts, GPU computing, WebGL2 and plain JavaScript in an experiment that makes complex physical systems tangible and interactive. Explore the simulations, change their parameters, observe the results, and dive into the code if you're curious about how everything works.

