SurfZar: Real-Time 3D Algebraic Surface Visualizer & Hybrid GPU Solver in WebGL2
Computer GraphicsTypeScript & WebOctober 14, 2026• 4 min read

SurfZar: Real-Time 3D Algebraic Surface Visualizer & Hybrid GPU Solver in WebGL2

From my 2011 iPhone 3GS thesis (iSurfer) to closed-form Cardano/Ferrari root solvers, interval raymarching, dual-sided PBR shading, and watertight STL 3D printing in the browser.

Table of Contents (6 sections)▸

1. Origins: From an iPhone 3GS in 2011 to Modern WebGL2#

Fifteen years ago, for my software engineering thesis at ITBA (Instituto Tecnológico de Buenos Aires), I built iSurfer—an interactive algebraic surface renderer for the iPhone 3GS. Inspired by the IMAGINARY open-mathematics project and Oberwolfach's SURFER, the challenge in 2011 was brutal: mobile CPUs could not evaluate millions of polynomial ray intersections per frame, so I had to write a custom ray tracer inside dynamically compiled OpenGL ES 2.0 GLSL fragment shaders running on the PowerVR SGX535 GPU.

SurfZar (surfzar.vercel.app) brings that vision into the modern browser with Next.js, React 19, Three.js (React Three Fiber), and custom WebGL2 GLSL shaders—requiring zero installation, zero plugins, and zero backend compute.

SurfZar 3D Studio Live TurntableClick to zoomSurfZar 3D Studio Live Turntable


2. Rendering Pure Implicit Zero-Sets f(x,y,z)=0f(x, y, z) = 0#

Unlike conventional 3D engines that approximate curved surfaces with triangle meshes, SurfZar directly renders continuous zero-level sets of implicit polynomial and transcendental equations in R3\mathbb{R}^3:

S={(x,y,z)∈R3∣f(x,y,z)=0}\mathcal{S} = \{(x, y, z) \in \mathbb{R}^3 \mid f(x, y, z) = 0\}

For every pixel on the screen, a viewing ray r(t)=o+td\mathbf{r}(t) = \mathbf{o} + t\mathbf{d} is cast through a bounding volume (Box, Sphere, Cylinder, or Torus). Substituting the ray equation into f(x,y,z)=0f(x, y, z) = 0 reduces the 3D surface intersection problem to finding the smallest positive real root t>0t > 0 of a univariate function g(t)=f(o+td)=0g(t) = f(\mathbf{o} + t\mathbf{d}) = 0.

SurfZar Studio Rendering the Barth SexticClick to zoomSurfZar Studio Rendering the Barth Sextic


3. The Hybrid Mathematical Engine: Analytical Solvers + Interval Raymarching#

A single numerical method cannot render both low-degree smooth manifolds and high-degree singular surfaces without artifacts. SurfZar parses the user's mathematical expression into an Abstract Syntax Tree (MathEngine.ts), classifies its polynomial degree, and compiles specialized GLSL evaluation paths:

DegreeFormulationGPU Solver StrategyExample Manifolds
1–2Linear & Quadric formsExact quadratic formulaSphere, Cylinder, Hyperboloid, Cone
3P3(t)=c3t3+c2t2+c1t+c0P_3(t) = c_3 t^3 + c_2 t^2 + c_1 t + c_0Cardano-Tartaglia closed-form cubic solverClebsch Diagonal Cubic, Cayley Cubic, Ding-Dong
4P4(t)=c4t4+c3t3+c2t2+c1t+c0P_4(t) = c_4 t^4 + c_3 t^3 + c_2 t^2 + c_1 t + c_0Ferrari closed-form quartic resolventTorus, Steiner's Roman, Kummer, Cushion
5–6Quintics & SexticsMulti-interval root isolation + Bisection (12 iters) & Newton-Raphson (8 iters)Barth Sextic (65 icosahedral singularities), Citric
Transcendentalsin⁡,cos⁡,tan⁡,exp⁡,ln⁡,x3\sin, \cos, \tan, \exp, \ln, \sqrt[3]{x}High-precision adaptive interval raymarcher with near-miss detectionGyroid, Schwarz P, Calabi-Yau, Topological Waves

Solving Singularities and Thin-Sheet Artifacts#

When rendering classic algebraic surfaces like Steiner's Roman Surface or the Barth Sextic, two notorious GPU shader artifacts appear:

  1. Parabolic Vertex Halo Noise: Along self-intersecting axes where ∇f=0\nabla f = \mathbf{0}, standard sign-change detectors miss grazing roots or trigger false positives. SurfZar validates local extrema and near-miss intervals before discarding or refining a root.
  2. Two-Sided Manifold Orientation (rayHitSign): Implicit surfaces partition space into interior (f(x,y,z)<0f(x,y,z) < 0) and exterior (f(x,y,z)>0f(x,y,z) > 0). By tracking the sign of ff along the approaching ray prior to root refinement, SurfZar prevents normal-flipping shimmer on thin sheets and shades Side A (Frontface) and Side B (Backface) with independent PBR materials, normal maps, metallic/roughness parameters, and HDRI environment reflections.

Barth Sextic 65 SingularitiesClick to zoomBarth Sextic 65 Singularities


4. Parametric Timeline Animation & Watertight 3D Printing#

Beyond static inspection, SurfZar is a complete creative studio for mathematical visualization:

  • Multi-Track Keyframe Dope-Sheet: Animate parameters a,b,c,d∈[−5,5]a, b, c, d \in [-5, 5] alongside continuous time TT over a 0–10s timeline with linear, step, and smooth cubic interpolation, plus direct WebM video capture and 4K transparent PNG snapshots.
  • Dynamic Cross-Section Clipping: Slice through ±X,±Y,±Z\pm X, \pm Y, \pm Z axes in real time to inspect internal chambers inside minimal surfaces like the Gyroid (sin(x)cos(y) + sin(y)cos(z) + sin(z)cos(x) = 0).
  • Marching Cubes STL / OBJ Export: With a single click, SurfZar polygonizes the implicit field into a watertight triangle mesh ready for 3D printing in Bambu Studio, PrusaSlicer, Cura, or Blender.
  • Lossless URL State Serialization: Every equation, camera matrix, dual-sided PBR material, clipping plane, and keyframe track compresses into a shareable #share=... URL hash.

Parametric Morphing AnimationClick to zoomParametric Morphing Animation


5. Try SurfZar Live#

Share or cite this engineering article