Clouds/Stars in the sky?

Started by
8 comments, last by DalTXColtsFan 21 years, 2 months ago
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
Advertisement
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.
[size="1"]
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.
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
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).
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).
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.
Why do you have to disable depth testing when you draw a skybox? My skybox looks the same either way.
disabling depth test is faster and you want to make sure everythings else are drawn in front of the sky box, not behind it
Draw the stars using points. Then add some blur using lines that project out from the stars. Thatll look good.

This topic is closed to new replies.

Advertisement