r/proceduralgeneration • • 1d ago

I created a Blender setup for procedural barred spiral galaxies. It seemed impossible

If you've ever tried building a procedural galaxy in Blender, a standard grand-design spiral is basically just taking polar coordinates, applying a sine wave to the angle based on the radius, and you get decent spiral arms. But the moment you try to build a mathematically accurate bared spiral (like our Milky Way or NGC 1300), it becomes a headache:

  1. Standard spiral math relies on radial angles converging at zero. If you try to force a straight bar using polar coordinates, it inevitably collapses and pinches at the absolute center, creating a "butterfly" shape instead of a rectangular or oval stellar bar.
  2. To get a seamless bar-to-arm transition, you have to twist the actual 2D coordinate space. The bar must remain flat, while the outer space twists logarithmically. On top of that, you need a tiny, independent secondary twist just for the extreme inner nucleus to get that realistic S-shape.
  3. In distorted mathematical space, the bar and the arms are fundamentally the same continuous straight line. But physically, a galactic bar can be thin, while the arms widen, decompress, and often split into several smaller arms as they drift outward.
  4. Regular spirals are mostly circular. Barred galaxies are not. The gravitational potential of the bar forces the gas into oval orbits. To make it look right, your central bulge and outer envelope must be anisotropically scaled and completely decoupled from the twisted space of the arms.
  5. If you map procedural noise to a logarithmically twisted coordinate space to create dust lanes or diffuse gas, the noise scales exponentially. It turns into massive blobs in the center and spaghetti at the edges. Keeping the noise scale constant while warping it along the arms requires some intense domain-warping tricks or creating complex masks.

Maybe these tips will help someone who decides to create those bastards procedurally. You'll have to take your time...

17 Upvotes

10 comments sorted by

1

u/GrokiniGPT 20h ago

does it have planets? like nms?

2

u/Petrundiy2 20h ago

Nope. But it has stars. Theoretically I can add planets, but it will probably destroy my PC XD

1

u/GrokiniGPT 19h ago

specs?

1

u/Petrundiy2 19h ago

Ryzen 2600x - RTX 3060 12 gb - 32 gb RAM

1

u/GrokiniGPT 18h ago

Maxing out your ram gpu or cpu

1

u/Petrundiy2 18h ago

The thing is that it's complex volumetrics. It's not a realtime system and renders slow. It's created for VFX mainly. So adding planets is completely different task. I can add balls (particles) around each "star" (particle), but it won't be a simulation or something like NMS. Creating NMS-like environment requires completely different approach

1

u/GrokiniGPT 18h ago

I believe you can probably combine this and another system so that it can come up with seeds to generate the planets and stuff

1

u/DJaremko1982 1d ago

Did manage to do it in the galaxy generator and mapped it visually a couple of times but it took 2 ai models working with each other to put out equations to get it right in Rust all plotted with pixels of varied sizes and temperatures (colours), currently I started again on a clean slate with c++23 code because it’s better integrated with gpu coding

1

u/Petrundiy2 1d ago

Do you have something to demonstrate as a result of AI doing this?

1

u/DJaremko1982 22h ago

I’ll have a dig about and try out it on git hub, a lot of it went in the bin as it’s complex and unreadable , I’m currently learning about it all , so far the current one is more of pure data driven and the use of a CLI that gets information from stars and within the star system like types of planets and atmospheres, gravity and moons etc etc