Advertisement

Stary Nights

Started by September 14, 2000 04:05 PM
6 comments, last by FrontierControler 24 years, 2 months ago
Ok guys, another quickie, i am trying to come up with different ideas as to how to implement a REALISTIC 3-D background of stars in my Demo. Ive seen some other demos just "fake" random points in the background, but i need to have something consistent, so that when you see stars, turn away, and turn back, those stars are still there. I thought of using stray triangles way in the background with different colors... but it lacks authenticity. Ever play FREESPACE? Notice how when you move, the stars STREAK slightly across the blackness, kinda emphsising movement... something like that...
I think ill experiment with the partical engine... thanks again Nehe...
And by the way, i just remembered a feature in Direct3dRM where you can "pick" out 3dObjects using the mouse. Is there anything like that in Open GL???


Advertisement
You could always use a texture mapped sphere that surrounds the world. Winding it so that the shown faces are inside, of course. I say a textured sphere instead of a cube because with a cube there''s a more definate edge between the two.

Of course, if you wanted to have actual polygons, with a single bright colour, you could put tiny tetrahedrons all over the place, but that would be more cpu intensive because it has to keep track of every object.

If you wanted to go one step further on that and make the freespace effect that you talked about (I haven''t seen it, just assuming what it looks like from your description) then you could have multiple tetrahedrons at each point overlapped with varying intesities of colour. When the camera moves, set the star overlays to move, moving the brightest one and having a trail of dimmer ones.

S.
hi

"pick out 3dObjects using the mouse"
let''s go to ogl superbible
It ''ll avoid difficult explanations

Eclipse de Soleil par notre Lunelunasol
use a skysphere + the selecti9on buffer
I tried to use a big sphere (500 polygons) for background stars, but the FPS went down by more than 50%. I thought it might be because of so many huge polygons, so I tried a cube. Slowed down almost as much as the sphere. My original texture was 1024x1024, so I thought maybe that''s too big and tried 256x256. Same result.

What am I doing wrong?

-Jussi
Advertisement
You''re not doing anything wrong

Big primitives mean big fillrate reductions...

The upside of the skybox method is that you DON''T have to clear the screen - your skybox will draw over everything. That should offset the speed reduction a little.

You still clear the Z buffer tho.

Paul Groves
pauls opengl page
paul's opengl message board
Paul Grovespauls opengl page
Get skies at http://www.mapcore.com/

My skybox:




float skysize = 1500, skymargin = 0.01; //skymargin
//extends the sides
//a bit beyond where
//they intersect to
//reduce edge repetition
//thingies.


void drawsky()
{
glBindTexture(GL_TEXTURE_2D, box[0]);

glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1 * (skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)), (-1 * skysize));

glTexCoord2f(1, 0);
glVertex3f((skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)), (-1 * skysize));

glTexCoord2f(1, 1);
glVertex3f((skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)), (-1 * skysize));

glTexCoord2f(0, 1);
glVertex3f(-1 * (skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)), (-1 * skysize));
glEnd();

glBindTexture(GL_TEXTURE_2D, box[1]);

glBegin(GL_QUADS);
glTexCoord2f(1, 0);
glVertex3f((-1 * skysize), -1 * (skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)));

glTexCoord2f(0, 0);
glVertex3f((-1 * skysize), -1 * (skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)));

glTexCoord2f(0, 1);
glVertex3f((-1 * skysize), (skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)));

glTexCoord2f(1, 1);
glVertex3f((-1 * skysize), (skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)));
glEnd();


glBindTexture(GL_TEXTURE_2D, box[2]);

glBegin(GL_QUADS);
glTexCoord2f(1, 0);
glVertex3f(-1 * (skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)), skysize);

glTexCoord2f(0, 0);
glVertex3f((skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)), skysize);

glTexCoord2f(0, 1);
glVertex3f((skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)), skysize);

glTexCoord2f(1, 1);
glVertex3f(-1 * (skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)), skysize);
glEnd();


glBindTexture(GL_TEXTURE_2D, box[3]);

glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(skysize, -1 * (skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)));

glTexCoord2f(1, 0);
glVertex3f(skysize, -1 * (skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)));

glTexCoord2f(1, 1);
glVertex3f(skysize, (skysize + (skysize * skymargin)), (skysize + (skysize * skymargin)));

glTexCoord2f(0, 1);
glVertex3f(skysize, (skysize + (skysize * skymargin)), -1 * (skysize + (skysize * skymargin)));
glEnd();


glBindTexture(GL_TEXTURE_2D, box[4]);

glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(-1 * (skysize + (skysize * skymargin)), skysize, -1 * (skysize + (skysize * skymargin)));

glTexCoord2f(1, 0);
glVertex3f((skysize + (skysize * skymargin)), skysize, -1 * (skysize + (skysize * skymargin)));

glTexCoord2f(1, 1);
glVertex3f((skysize + (skysize * skymargin)), skysize, (skysize + (skysize * skymargin)));

glTexCoord2f(0, 1);
glVertex3f(-1 * (skysize + (skysize * skymargin)), skysize, (skysize + (skysize * skymargin)));
glEnd();

}

Edited by - Chazz on September 16, 2000 12:04:41 PM
-Chazz

This topic is closed to new replies.

Advertisement