Jump to content
  • Advertisement
Sign in to follow this  
laeuchli

OpenGL Best way to render stars?

This topic is 4003 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
</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

Share this post


Link to post
Share on other sites
just use textured quads, its what ive donw with the skybox here www.zedzeek.com

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!