Jump to content
  • Advertisement
  • entries
  • comments
  • views

Playing with starfields/galaxies

Sign in to follow this  


Recently i've been playing with procedural generation of a volumetric galaxy (no less!). For this i decomposed the task into 3 parts:

1. Generating a background starfield.
2. Generating a volumetric galaxy (made of particles, so that you can "fly" into it)
3. Generating nebulas.

1. Generating a background starfield:

No real difficulty, except that the starfield must be rendered as a skybox, so the seams have to match. Ok, so i lied, it's not that easy. I ended up generating a cube, and for each face, using a border inside the image. The seams become very important when you start to blur the 6 images: the colors must perfectly match along the seams.

The starfield is procedurally generated by applying a set of functions to the cube: many types of noise (fBm, perlin), many operators (add, multiply, scale, blend), plus special functions (adjust brightness & contrast, blur). To get a good starfield the trick is simply to play with all the parameters and use the correct set of colors & operations. I ended up generating 5 layers of stars, each with a different redshift and scale, and blending everything together.

2. Generating a volumetric galaxy:

This process is based on an octree. The octree is split based on the distance to the camera. When a node is split, some stars are placed in the cell. The density and attributes of the stars (like brightness/color) are based on some mathematical functions supposed to generate a spiral galaxy, with many arms and a central bulge. In practise with all the blending, the arms end up not being that visible.

The galaxy is displayed as a set of particles with alpha blending. It is separated in two: rendering "halos" (with a size of many light years), for far away stars; and rendering "dots" for closer stars.

3. Generating nebulas:

I'm still early in that part, but i think it might be very promising. I use a 3D volumetric grid with a CFD solver (Navier-Stokes equations). Some gaz is placed at the center of the grid, and some velocities are generated to simulate an "explosion" (nebulas are generated by exploding stars). After time stepping the simulation a few times, a volumetric cloud appear.

It takes approximately one second to step the simulation for a 64x64x64 grid. I hope to do that either as a pre-process step and to save the results to the disk, either to generate nebulas in a low-priority thread. That way, when flying into the galaxy, if the camera comes close to a nebula, one is loaded from the disk or taken from a pool of generated nebulas from memory.

I haven't started to color and shade the nebula yet, but i think it's gonna look... interesting :)
Sign in to follow this  


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!