As a slight departure from my usual projects I thought it would be nice to see an animated galaxy model. I was hoping that there would be star coordinate data freely available on t'interwebs, Hipparcos is one, but the data is only for relatively nearby stars so you just end up with a sphere of stars centred on the Sun - not very interesting.

So I changed tack and re-used my terrain mesh building code to load a picture of a galaxy as a height-map. I used this one (can't remember which galaxy it is though):

Obviously there is no 'height' as such in a flat image, to generate the galaxy disk and bulge I randomized the vertical coordinates, with the range being higher in the bulge and tapering off towards the edge of the disk. The colours of the 'stars' are the pixel colours in the image, after discarding pixels with a total luminance below a certain threshold, i.e. the resultant model does not have a 'star' for every pixel of the image, only the brightest ones.

Here's a side-on view:

Edge on:

Close-up:

The galaxy model is rendered using a 'point cloud' mesh re-used from my particle system code, each 'star' is a point-sprite with the shader creating a imposter sphere, blended with the stars behind it and ordered by distance. With the cut-off threshold I applied there are about 50K stars in the model and it renders way above 60 FPS, though obviously goes slower as more stars are added.

I'm quite pleased with the results for what turned out to be relatively little work using (largely) existing code. It's far from perfect and there's plenty more that could be done: it doesn't look too great close-up (perhaps to be expected), and the blending can look a bit clunky sometimes (need to experiment with other functions). I'd be interested to see if anyone else has tried anything similar.

So I changed tack and re-used my terrain mesh building code to load a picture of a galaxy as a height-map. I used this one (can't remember which galaxy it is though):

The structure matches our own galaxy. The short central bar, and the branching arms match quite well. There sure are enough barred spiral galaxies which looks similar, but bets are that this is a visualization of our own galaxy.

The structure matches our own galaxy. The short central bar, and the branching arms match quite well. There sure are enough barred spiral galaxies which looks similar, but bets are that this is a visualization of our own galaxy.

Expect you're right, I think I remember finding that image when searching for Milky Way star data, and our galaxy is suspected to be a barred spiral.

Its not our galaxy. It is one that is like ours... we think. Remember we only decided it was a bar galaxy pretty recently.

The star catalogs work for close stars. That is ones where we can measure the distance via the parallax method. This works out to a few 100lty IIRC. The milky way is about 100,000lty across, and contains something like 100 to 400 billion stars.

Interesting approach.

I have no special talents. I am only passionately curious.--Albert Einstein

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org