View Full Version : How to draw a Sun?
I want to draw a Sun, and i want the sun to emit light how can i do that with light and matrial propeirty ..
03-30-2001, 05:34 AM
This is how I did it.
1. Enable lighting and use a directional light point at where you are going to draw the sun.
2. Set up an Emmissive material property
3. Bind any texture you might want to use, using GL_MODULATE for the glTexEnv
4. Draw the sun
5. Setup positional light at the location of the sun, and disable directional light. (Or turn directional light into the positional light.)
6. For each planet, set material, texture, set proper translation/rotation, and draw.
03-30-2001, 05:50 AM
Personally I just glDisable lighting when drawing a sun, rather than mucking about with material emissive components. This may or may not be faster, depending on how bright your driver is, but it certainly shouldn't be slower.
As a side note, most space-sim type things seem to draw the sun MUCH bigger than it ought to be, for dramatic effect. At one AU, the distance from Earth to Sol, the sun's diameter should subtend an angle of about 0.52 degrees. For a 60-degree FOV at 640x480, that's only about 4 pixels across, which looks a bit weedy unless you slap a bunch of fancy glare effects on top.
03-30-2001, 09:51 AM
Well the sun I created was part of a full solar system with planets that orbit around it and moons that orbit around the planets. (And the way I designed it, the moons could have moons, and those moons could have moons of their own, and so on, and so on.) http://www.opengl.org/discussion_boards/ubb/smile.gif I liked the effect that the emmissive material added to the sun in this case. I wasn't really going with realism for the solar system as much as just doing it as a demo for how to use transformations in OpenGL. In my case, the example (a fictional solar system, not meant to be an exact replica of our own) has the planets too big and probably too close to the sun, as opposed to having the sun too big.
I didn't stop to think that the poster might actually be thinking a sun as seen from earth. http://www.opengl.org/discussion_boards/ubb/smile.gif In that case, I wouldn't bother with even modelling the sun and would probably just use a textured quad, and use a directional light based on the location of the sun.
03-30-2001, 02:40 PM
Heh. And I was assuming that you'd always draw the Sun as a 2D billboard...
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.