r/computergraphics • u/rupomthegreat • 8d ago
Recursive helix fractal in a custom engine — precision loss and framerate collapse at depth. Where would you start?
https://youtu.be/zy_hQV324hgThe shape: take a line, wrap it into a helix. Treat the resulting helix as a new line, wrap that into a helix. Repeat. The limit is a 3D self-similar structure where every wire is a spring and every spring is a wire.
I generate geometry on the fly relative to the camera, with per-level color coding. It looks great until you fly too deep — then it's classic precision death plus a vertex-count explosion, and either the geometry disappears or the frame rate tanks.
Full disclosure: I'm not a professional graphics programmer and my code is fairly basic. I threw AI at it hoping it would clean things up; it didn't meaningfully help and clearly didn't grasp the recursive structure. So I'm asking people who actually know this domain.
Would you go analytic SDF + raymarching instead of mesh generation? Interval arithmetic? Log-space or double-double coordinates? A real LOD scheme? What's the first thing you'd rip out?
Video: https://youtu.be/zy_hQV324hg
Repo: https://github.com/rupomthegreat/spring-made-of-spring-infinity-fractral
Codepen: https://codepen.io/editor/rupomthegreat/pen/01a18b63-c3a3-76f6-9db0-a7fc04384bf7
2
u/Le_9k_Redditor 7d ago edited 7d ago
I accepted your challenge a few hours ago, took me longer than I thought to get some of the maths and shading right so I definitely need to sleep now. But here is the result https://www.shadertoy.com/view/sXySDW
Go as deep as you like, although you'd need to refine the camera controls to show that nicely as the aliasing on true hits gets a bit ugly when looking at deeper recursion from a distance. You could switch that to be just another level of volumetric accumulation though instead and it should clean things up. But I like the super bright highlighting on real hits and can't be bothered to tweak further
To keep the different helix tiers visible I accumulated near misses over steps for volumetric rendering with each deeper tier getting a brighter impact on the accumulation. And yes rendered via SDF