PDA

View Full Version : The Sky



Andrea Rossini
03-21-2002, 10:33 PM
I want a texture for the background sky instead of
glClearColor(0,1,1,0) //cyan
How can this be done?

DFrey
03-21-2002, 11:19 PM
Do a search on this board for skyboxes. It has been discussed very many times, so everything you need to know should be readily available.

03-21-2002, 11:21 PM
You need to make a skybox or half a sphere, and then apply a 'sky' texure to it.

Or if angle doesn't change much, i.e. up and down, you could create a huge quad in the distance and then apple a sky texture to it. That sounds tacky and dirty to implement. Do a search on 3d skybox in google. You might get some useful hits.
Thats how i get insight into stuff i need for my programming. For example i'm donig some research into collision detection for spheres and i found some great sites with detailed information about collision detection and tidbits of code which you can use.

03-21-2002, 11:22 PM
oops, i was typing my post before the prior post was up. Cool! i can look around here for skybox algorithms too!

rIO
03-22-2002, 04:23 AM
It's a quite ewasy task :

build a box, apply to it 6 textures (maybe create them with software like bryce) so that they are a 90 camera view perpendicular to each box plane. (it is possible to do it also with only one texture but this will be "advanced stuff", and another good hint is to create more than one box at time)

then make the box(es) rotate, but NOT translate with the current camera, draw them with glDepthMask disabled and you are done.

rIO.sK http://www.spinningkids.org/rio

Jambolo
03-24-2002, 12:53 PM
Or (I stand corrected, rIO and DFrey), translate the skybox to follow the camera's translation. Like this:






gluLookAt( ex, ey, ez, cx, cy, cz, ux, uy, uz );
glPushMatrix();
glTranslatef( ex, ey, ez );
DrawSkyBox();
glPopMatrix();
...


[This message has been edited by Jambolo (edited 03-24-2002).]

DFrey
03-24-2002, 01:15 PM
You can do it either way. Either draw the skybox with only a rotation matrix set, then translate and draw everything else (which is the method I prefer as then the size of the box is independent of what follows), or you can use your approach and rotate the box then translate it, but then the box must really be bigger than anything else that gets drawn.

Jambolo
03-24-2002, 01:54 PM
Originally posted by DFrey:
You can do it either way. Either draw the skybox with only a rotation matrix set, then translate and draw everything else (which is the method I prefer as then the size of the box is independent of what follows), or you can use your approach and rotate the box then translate it, but then the box must really be bigger than anything else that gets drawn.

As long as it is drawn before anything else (with depth write and depth test turned off) it doesn't matter how big it is, right?
But that means that the depth buffer still has to be cleared. Is there a faster way? You could draw a really big box with depth write on, but there could be problems since it doesn't match the far clipping plane.

[This message has been edited by Jambolo (edited 03-24-2002).]