Archived

This topic is now archived and is closed to further replies.

DalTXColtsFan

Clouds/Stars in the sky?

Recommended Posts

I would like to learn how to have kind of a background image that somewhat scrolls to the left and right, like clouds in the sky, or the moon and stars at night. Is there a NeHe tutorial that accomplishes this? Thanks Joe

Share this post


Link to post
Share on other sites
Theres not a nehe tut that teaches this directly but you can learn it easily with the texture mapping tut.

Try adding 0.1 to each texture coordinate every frame. If it get to be greate than one clamp it back to zero (actually you can have values greater than one, but then GL has to clamp it for you).

Play with this til you understand the concept.

Instead of changing each coordinate you can perform transformations on the texture matrices. These work the same as the modelview and projection matrices in that you can translate and rotate etc and the transformation will affect the texture coords for you (like if you glTranslate it affects the vertices for you).

Have fun.

Share this post


Link to post
Share on other sites
i havent tested this out at all, but i imagine having a sphere that projects inwards that surrounds the entire view that rotates inversly to the camera could have a star map mapped to it.

hope that helps.

Share this post


Link to post
Share on other sites
OK, maybe I should take it one step at a time: What''s the most efficient way to just put a background gif on the entire window before rendering the rest of the 3D scene? I''ll worry about making it move second.

Thanks for the help.

Joe

Share this post


Link to post
Share on other sites
The most efficient : a uniform color

Well, a texture is what you need. And the geometry is really easy to setup. One quad is enough. You "just" have to compute the corresponding texture coordinates.

Though for more realistic environment, a cube may be more appropriate than a single quad, and the geometry is not really a problem either (8 points to t&l, a joke when we know todays cards capabilities).

Share this post


Link to post
Share on other sites
Oh and I forgot to tell. The cube technique is known as "sky box" that you may have heard/read of it for sure. It consists in rendering a cube centered around the camera, with depth buffer disabled, and should be rendered in the very beginning of the frame since it''s meant to clear the background.

There are alot of articles describing skyboxes over the Web. I''m pretty sure that gamedev articles have some. (click ''Articles & Resources'' in the header of this page).

Share this post


Link to post
Share on other sites
Thanks everybody, I got it working. I''ll probably play around with using a single quad like billboarding, a whole cube, or even a sphere.

I wasn''t "thinking outside the box" - I just assumed there would be a way to slap a bmp on the rendering context before starting to render in 3D.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why do you have to disable depth testing when you draw a skybox? My skybox looks the same either way.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
disabling depth test is faster and you want to make sure everythings else are drawn in front of the sky box, not behind it

Share this post


Link to post
Share on other sites