Spirulae: Web-Based Math Visualization

by Harry Chen - updated January 2024
GitHubGallery


3D Implicit Surface Grapher

3D Parametric Surface Grapher

Complex Domain Coloring Grapher

3D Complex Function Grapher

Implicit Surface Path Tracer
(powerful GPU required)

3D Implicit Mesh Generator (dev)
 

2D Vector Field Grapher (dev)

2D to 3D Mesh Generator (dev)

GPU-accelerated math function graphers in web browsers, both 3D and 2D.

This is a personal passion project. Back in 2022 I couldn't find a 3D graphing calculator with satisfying 3D implicit surface rendering on the internet, so I made one, and the development continued. I was initially inspired by raymarching demos on Shadertoy, but as I extended the equation parser and renderer to other types of math functions, currently implemented function graphers are not limited to implicit ones.

It is important to note that these function graphers are developed completely by my effort, and many features I implemented are biased toward personal use. Since I don't have much knowledge of advanced functions (especially the complex-variable ones, which I only found their graphs to be visually cool), I cannot guarantee the mathematical practicability and accuracy of these tools. If you have any suggestions or believe you are experiencing a bug, feel free to open an issue on GitHub.

The name "Spirulae" comes from the name of a deep-ocean cephalopod mollusk that has distinctive spiral shells. I consider myself a fan of spirals, so it shouldn't be surprising that you see a lot of spirals in examples.


Features

The equation parser implements the following features:

The 3D graphers have the following features implemented:

Experimental features (subject to change):


Working in Progress

Spirulae is under active development. Tools and features that are being developed include:

Features that may be implemented in the future (ordered approximately by priority):

Ongoing and proposed research topics (ordered approximately by progress):


Limitations

Spirulae has the following web dependencies:

Spirulae has the following known issues:

Spirulae is not available for commercial licensing due to C++ dependency Triangle and is currently distributed under GPLv3. Spirulae is previously distributed under the MIT license. Note that shader sources adapted from Shadertoy, namely this, this, and this, are separately distributed under CC BY-SA-NC 3.0 according to Shadertoy terms of service.


Frequently Asked Questions

Q: What libraries do Spirulae use?

To make Spirulae lightweight and compatible, I tried to write it with as few dependencies as possible. With the exception of MathJax for rendering LaTeX equations, the JavaScript equation parser and renderers are written from scratch without use of external libraries and frameworks, other than native browser APIs like WebGL. The C++ part that powers mesh generation is compiled to WebAssembly with Emscripten, which uses the following third-party libraries:

Spirulae also adapts shader sources from Shadertoy:

Q: How to draw shapes using equations?

Drawing meaningful shapes using equations is more about art techniques than rigorous mathematics. To get started, you can check Inigo Quilez's YouTube channel and videos like this one. I also have a Google Slide intended to introduce Desmos art to high school students that may cover similar principles and can be used as a dictionary.

Q: How does Spirulae evaluate functions on the GPU?

For readers with technical background, Spirulae recompiles shader every time the equation input or a graphing parameter is updated. Spirulae parses equations into postfix notation and generates code of a GLSL function that can be compiled. Automatic differentiation can be done in this step. Generated shader code can be found in the browser's F12 developer console.


Gallery

Note: This gallery has not been updated for a while.
To see more recent visual results, a gallery of unfiltered process screenshots can be found here. Note that the page is intended to be a progress overview rather than a showcase gallery.

Complex domain coloring

The gamma function in 3D

A sextic algebraic surface

A fractal with scalar field visualized

A clipped quintic implicit surface, with volumetrics showing isosurfaces

A parametric surface rendered in X-ray mode

A path-traced fractal