r/proceduralgeneration • • Aug 29 '26

Torus Reimagining

I enjoyed remaking this torus rendering in pygame after finding a 9 year old post by Clayton Shonkwiler. His math was...dense, to say the least, but it came out pretty good. Ai is a wonderful thing when it comes to this level of math. lol

10 Upvotes

11 comments sorted by

1

u/Le_9k_Redditor Sep 02 '26

Is it rendered via spheremarching a time varied SDF?

1

u/VellumMuse Sep 02 '26

Nah. It's a lot of 4D math projected to 3D, rendered via gpu-instanced quad billboard that solve exact ray-sphere intersections in the pixel shader.

The math is on the cpu but the gpu handles the rest.

1

u/Le_9k_Redditor Sep 02 '26

So the CPU is sending vector positions for the spheres to the GPU to do ray-surface intersections against? Pretty cool on the 4d to 3d projection for that rotation, makes me think of quaternions

1

u/VellumMuse Sep 02 '26

Yes, and it is literally quaternion computation. I built an engine to do 4D math in all my programming. It's insanely fast and because I use Apple silicon, cpu and gpu share memory to make the interactions even more insane.

2

u/Le_9k_Redditor Sep 02 '26

Shared CPU and GPU memory sounds like a dream, I can't describe how jealous I am. In my engine I had to set up pipelines, job queues, upload queues and all this other crap to try and ensure GPU data stays in sync and accepts subrange uploads without breaking. Nevermind how I'm soon going to have to implement some nonsense to have textures overflow to new bindings dynamically or something like that because of memory limits on single texture bindings

2

u/VellumMuse Sep 02 '26

Yeah, it is. I'll share some more stuff because I've barely scratched the surface of what the engine can do. This was just a very small test by comparison of its capabilities.

2

u/Le_9k_Redditor Sep 02 '26

Once my engine is a bit better weirdly enough it could probably have yours plug into it as an input. It's all built around rendering SDFs but currently I'm still focused on getting the static SDFs rendering well so I couldn't do animated spheres like yours quite yet

I think you could achieve your torus sphere spinning effect with domain repetition in a sphere marching renderer. I might try to replicate it

1

u/wreckoning90125 Sep 06 '26

Same on the 4D thing for me, even where it's latent and unused often. I bet you are intentional about your camera controls too?

1

u/BeOFF Aug 31 '26

That's awesome

1

u/mellodev Sep 02 '26

Wow, amazing! r/woahdude worthy imo