<p>I am trying to write a spaceship simulator. One problem I've hit into is how to best simulate the background of space with its stars. I don't need it to be faithful to the real thing with constellations and everything, but my attempt of uniformly distributing random points on the celestial sphere produced... unnatural-looking starry backgrounds, for reasons I can't put a finger on.</p>

<p><strong>Is there a way to "realistically" distribute random "stars" in space?</strong> I'm language agnostic, so feel free to code in the language you're most comfortable with; I'll adjust. :)</p>

CC BY-SA 3.0
2016-08-16T12:51:54.893Z
IS taking the real star position data and pojecting it on your map considered realistic enough?
joojaa
CC BY-SA 3.0
2016-08-16T12:57:55.317Z
You can find data here: http://www.astronexus.com/hyg
joojaa
CC BY-SA 3.0
2016-08-16T19:06:09.997Z
Maybe calculate random 3D positions for the stars and then project them onto a sphere. Their brightness depends on the distance from the sphere center.
tmlen
CC BY-SA 3.0
2016-08-16T19:52:34.583Z
Maybe you could add a screenshot of your current results versus what you're looking for (e.g. a photo of a real starry sky that you'd like to imitate)? Otherwise, we're just guessing what "unnatural-looking" means here.
Nathan Reed
CC BY-SA 3.0
2016-08-18T06:07:11.843Z
Maybe you could look into poisson sampling, you can define some density function and transform that into distributed points of fairly convincing random distribution. Check here http://devmag.org.za/2009/05/03/poisson-disk-sampling/
PaulHK
CC BY-SA 3.0
2016-08-20T13:00:50.700Z
Is the starfield to be a fixed background? That is, do your spaceships move slowly enough that the stars do not need to move?
trichoplax is on Codidact now
<simulation>
How do I simulate a starfield?
Joe Shaka Khul
# How do I simulate a starfield?

(Asked by: username_0 on 2016-08-16)

I am trying to write a spaceship simulator. One problem I've hit into is how to best simulate the background of space with its stars. I don't need it to be faithful to the real thing with constellations and everything, but my attempt of uniformly distributing random points on the celestial sphere produced... unnatural-looking starry backgrounds, for reasons I can't put a finger on.

**Is there a way to "realistically" distribute random "stars" in space?** I'm language agnostic, so feel free to code in the language you're most comfortable with; I'll adjust. :)

**Tags:** simulation

> **Comments:**
> **username_1**: IS taking the real star position data and pojecting it on your map considered realistic enough?  
> **username_1**: You can find data here: http://www.astronexus.com/hyg  
> **username_2**: Maybe calculate random 3D positions for the stars and then project them onto a sphere. Their brightness depends on the distance from the sphere center.  
> **username_3**: Maybe you could add a screenshot of your current results versus what you're looking for (e.g. a photo of a real starry sky that you'd like to imitate)? Otherwise, we're just guessing what "unnatural-looking" means here.  
> **username_4**: Maybe you could look into poisson sampling, you can define some density function and transform that into distributed points of fairly convincing random distribution. Check here http://devmag.org.za/2009/05/03/poisson-disk-sampling/  
> **username_5**: Is the starfield to be a fixed background? That is, do your spaceships move slowly enough that the stars do not need to move?  

---

## 0 answers

