Rezmason / matrix

matrix (web-based green code rain, made with love)
https://rezmason.github.io/matrix
MIT License
3.29k stars 212 forks source link
canvas html5 javascript matrix matrix-digital-rain matrix-rain regl webgl webgl-computer-graphics

Matrix screenshot

matrix (web-based green code rain, made with love)

News Update September 2022: this project was featured in Vice Motherboard, along with insight into the effect from Lilly Wachowski.

Quick Links

Variants

Typography

Concept

Contents

About

This project is a web implementation of the raining green code seen in the Matrix franchise. It's built right on top of the functional WebGL wrapper, REGL, with beta support for the upcoming graphics API WebGPU; its previous Three.js version is maintained in a separate branch.

This project runs right in the web browser; you can serve it with any HTTP/HTTPS server, with no additional setup. For example, on a Mac you can point a Terminal shell at a local copy of the project and run a simple HTTP server with Python: cd /path/to/the/project ; python3 -m http.server

Goals

There are four kinds of Matrix effects people call "digital rain":

  1. The green symbols that "rain down" operators' screens endlessly
  2. Scenes from within the simulation that depict green symbols streaking across everything
  3. The films' opening title graphics, which dazzle viewers and then draw them into the world of the franchise
  4. The "dialing" visualization at the opening of The Matrix and Resurrections

A motivated fan can attempt to portray any of these. However, this project focuses specifically on #1 and #3— an endless effect, visually stunning and mystifying, that feels right at home on any screen.

The following criteria guided the development process:

Sidenote: other people's Matrix effects

The number of implementations out there of this effect is a testament to the size of the film's impact on popular culture. For decades, I've enjoyed searching for and comparing them from time to time. That's probably how you arrived here— it's fun to see what kinds of solutions different people come up with to a problem, when the process is purely recreational and its success is subjective. I myself tried and failed to make the effect many times over.

Some of the earliest, roughest versions were made after the film hit theaters in March, but before it was released on home media in October— people were recreating the effect purely from memory. Others probably used the official screensaver as a reference, which was made by the time-strappped developers of the (excellent, defunct) official site from the images and multimedia tools they had available.

Customization

You can customize the digital rain quite a bit by stapling "URL variables" to its URL— by putting a '?' at the end of the link above, and then chaining together words, like this:

https://rezmason.github.io/matrix/?width=100&fallSpeed=-0.1&effect=none

Now you know link fu. Here's a list of customization options:

Troubleshooting

There haven't been many reported issues yet that weren't quick fixes, but one has stood out: many visitors have previously disabled hardware acceleration in their Chrome browsers, at the advice of well-meaning Internet websites.

What this does is cause Chrome to fall back to SwiftShader, a software renderer that runs projects like this one at a much slower rate. Because of this, if you are seeing serious performance issues on Chrome, it's recommended that you ensure hardware acceleration is enabled in your browser settings.

Future directions

This project is still in active development, but some upcoming features are worth mentioning.

Friends of the project

Colophon

The Coptic glyphs in the "Paradise Matrix" version are derived from George Douros's font "Symbola", due to their similarity to the script in CG II of Nag Hammadi. If a 4th century Gnostic scribe trolled Athanasius over IRC, it might look like this.

The Gothic glyphs in the "Nightmare Matrix" version are derived from Dr. jur. Robert Pfeffer's font "Silubur", which are inspired by the uncial script found in the Codex Argenteus. If a werewolf emailed a vampire in the 6th century, it might look like this.

The glyphs used in the "Palimpsest" and "Twilight" versions are derived from Teague Chrystie's font "Huberfish", a fictitious alphabet that comes in several styles. If a spacedock technician bought a soda from a vending machine in an cool utopian future that will never happen, it might look like this.

Other details

The glyphs are formatted as a multi-channel distance field (or MSDF) via Victor Chlumsky's msdfgen. This format preserves the crisp edges and corners of vector graphics when rendered as textures. Chlumsky's thesis paper, which is in English and is also easy to read, is available to download here.

The raindrops themselves are particles computed on the GPU and stored in textures, much smaller than the final render. The data sent from the CPU to the GPU every frame is negligible.