Best way to render stars?

Started by
8 comments, last by laeuchli 16 years, 8 months ago
Dear All, I'm trying to render a realistic star field ,as seen from earth. I have the positions and magnitudes from a star catalogue, and am currently rendering them as points with various levels of alpha. This works ok, but doesnt look great, and I'm trying to think of a better rendering method. One way I considered was using point sprites, however then I'd need a star texture, and I'm not sure what would look good. Another thought I have on this is that I should increase/decrease the size of the points based on thier magnitude, and not just fade them out. I think theres a good way to do this in DirectX while keeping just one DrawPrimitive call. Is theres a way to do this in OpenGL? It seems like I'd have to keep calling a glPointSize, or setup the quads myself, which seems like kind of a pain. Any suggestions would be greatly apprciated. Regards, Jesse
Advertisement
Well, stars ARE really little points (sub-pixel), most of their "size" is coming from lens flare and atmospheric scattering.
So the texture you need is either a lens flare texture or a simple blurry circle. (but you can try other things and experiment what LOOKS good in practice)

P.S.: I guess the vertex attribute called D3DFVF_PSIZE is exactly what you need. Of course you can always use the distance from the viewer to set the point sizes ;)
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)
</P.S.: I guess the vertex attribute called D3DFVF_PSIZE is exactly what you need. Of course you can always use the distance from the viewer to set the point sizes ;)/>
Haha doh, of course. I'm silly. Thats probably the way to go, as theres no D3DFVF_PSIZE equiv as I understand it in opengl. Anyway have any point sprite star textures that worked well?
Regards,
Jesse
just use textured quads, its what ive donw with the skybox here www.zedzeek.com
Download the trial of the game "Pax Galaxia" or "Pax Solaris" It has 4 or 5 nice star textures with alpha maps.
Hope this helps ;)
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)
I did a stellar renderer a few years ago using point sprites. I used a vertex program to compute the sprite size based on magnitude (and in the 3D case, distance), a mipmapped texture encoding a gaussian, and a fragment program to modulate the color of the gaussian based on spectral type. The end result closely resembles long-exposure astro photography, and easily runs realtime, even for millions of stars. Screeny. I've been meaning to convert this over to GLSL, but I haven't gotten around to it. If you'd like to look at the code, it is part of Electro.
Quote:Original post by Trurl
I did a stellar renderer a few years ago using point sprites. I used a vertex program to compute the sprite size based on magnitude (and in the 3D case, distance), a mipmapped texture encoding a gaussian, and a fragment program to modulate the color of the gaussian based on spectral type. The end result closely resembles long-exposure astro photography, and easily runs realtime, even for millions of stars. Screeny. I've been meaning to convert this over to GLSL, but I haven't gotten around to it. If you'd like to look at the code, it is part of Electro.


Holy crap! That looks awesome!
Mike Popoloski | Journal | SlimDX
Wow that does look incredibly good Trurl. Where in the source is the texture you used? I've been pawing though, and cant seem to find it.
Regards,
JEsse
The texture is just a gaussian, so it's easy to generate procedurally. No need to store it on disk. The gaussian texture generator is star_make_texture() in star.c.
Oh I see. Well thanks, that gives me a lot to go on.
Regards,
Jesse

This topic is closed to new replies.

Advertisement