Creating good star fields is not as simple as it might seem. One approach (the physically elegant one) is to place some geometric object at the right location, generally a sphere at some fixed large distance from the center of the model. This has the problem of what primitive to use and how big should that primitive be. If the star object is too small then it will be missed by the raytracer, even with a high level of antialiasing. If the primitive is too large then the stars won't look like point sources. The same arguments apply to the distance the stars are placed from the center of the model. If it's too close then the stars will look large, if too far away then the stars will be missed by the raytracer. Fiddling the characteristics of the star positions depending on the typical camera position is tedious.
One way around the above problem is to create a large sphere around the model and map a high resolution texture onto that sphere. This immediately solves the problem with the size of the stars, they will appear the same size irrespective of the radius of the sphere the texture is mapped onto. One implication is that the size of the stars will vary depending on the dimensions of the rendered image, so a different texture size may be required for small rendered images compared to large images.
The following image starmap.png has been created as a star map to be applied as a texture to a sphere using standard spherical texture coordinates. It is based upon real star positions. The magnitude, and therefore apparent brightness, is mapped onto the size of the dots. To assist with antialising, the stars are blurred. Note also the distortion (stretching) of the stars towards the top and bottom, this exactly compensates for the distortion introduced by the spherical (polar) texture mapping. This texture is created for images rendered around the 1000 pixel range.

PovRay description
The following illustrates how this might be applied as a texture map star sphere in PovRay. The exact settings for the finish {} may vary depending on other aspects of the model environment.
/* Star field */
sphere {
<0,0,0>, 1
hollow
pigment {
image_map {
png "starmap.png"
map_type 1 /* Spherical */
once
}
}
finish {
ambient 2 /* Inverse of earlier global ambient level */
diffuse 0
}
scale 1000000 /* Depends on model units */
}
Other issues
The distance the stars or star sphere with the texture map are placed cannot be infinitely distant or even at the real distance because of realities in the numerical systems used in computers. Closer stars mean that they are not necessarily invariant on the sky as the camera is moved around...as they are in reality. One solution to this is to center the star field sphere about the camera, in which case the stars don't move in relation to the camera.
The dynamic range of the usual 8 bit greyscale range (256 levels of grey) is not nearly enough to represent the dynamic range of star brightnesses. This could be helped by using 16 bits per (r,g,b) or moving towards a 16 bit luminance model.
|
Ever wanted to include real star positions in your models or renderings? The data here will let you do that, it provides the positions in both polar and cartesian coordinates, it also gives the visual magnitude. It contains all the stars that are brighter than magnitude 6.5, stars visible to the human eye have a magnitude around 4 (depending on the lighting conditions from where you're viewing). There are over 9100 stars listed. This file gives the positions of the 9000 brightest stars. The 6 columns are labeled as follows
A useful include for C applications is: stars.c.
|
The following is the mapping onto a cylinder, including the top and bottom caps. The cylinder covers -50 to 50 degrees vertically, the planar caps being therefore 50 to 90 degrees (north pole) and -50 to -90 degrees (south pole).
|
Plane (inscribed circle) above 50 degree declination PNG
|
Plane (inscribed circle) below -50 degree declination PNG
|
|
PNG
| |
It was originally intended to be used as a physical star projector, namely to be printed and stuck together to form a real cylinder with a bright light source on the interior. To this end there are alignment points, a red star at the north pole, a blue point at the south pole, green points spaced at 1 degree intervals across the boundaries and also showing positive right ascension at the equator. It is expected that these alignment markings would be removed with a physical marker or digitally once the alignment is understood.