PDA

View Full Version : skybox animation



elgawin
03-09-2011, 08:05 AM
hi

I read some documentation about skybox. But they don't look very nice.

I would like to have my skybox to move slowly with the user. Are there any special mathematics behind, or is it just done how we want to it it ? I mean I can make the skybox move slowly, but there is no real mathematics or physics behind. But maybe there should ?

ZbuffeR
03-09-2011, 03:29 PM
What do you mean, move with the user ? Just stay at the same relative distance from the user, whatever its moves ?

elgawin
03-10-2011, 03:34 AM
hi !

thank you for your answer !

I mean I would like the skybox to move slowly according to the user, to make an impression that it's not static and far "mountains" that move slowly, because they are far. If I don't make move the skybox they are static and the animation doesn't look good at all: we have the impression that there is a real box surrounding the world, which I want to avoid. Making the skybox moves slowly helps to reduce this bad impression.

And I wanted to know if there are mathematics of physics that allow to calculate this ? Maybe according to the distance, to the speed of the user...

ZbuffeR
03-10-2011, 05:40 AM
Simply make your skybox 10x bigger.

Zenja
03-15-2011, 08:20 AM
Use a skydome instead of a skybox. By rotating the dome, you can give the illusion that the sky/clouds are moving. If you're casting shadows or drawing lens flare, then you'll have to sync that with the skydome rotation.

Kelvin
03-15-2011, 07:55 PM
> ... mathematics or physics behind ...

As I understand it, a skybox is usually used to simulate objects that are very far away -- so far away that local movement doesn't affect their apparent size or relative positions. The "mathematically correct" approximation here is to move the skybox exactly with the user.

For objects that are extremely far away (e.g. stars in the sky), the approximation will be essentially perfect. If you travel around the world (or to the moon and back), you can see different constellations, but their shapes and sizes don't change at all. The closer objects are, the less good the approximation is. Still good for the sun, not as good for mountains or clouds, but probably good enough.

With a little trigonometry, you can calculate the difference between apparent (to the user) object size on the skybox (always the same), and the apparent size of the object if the user were allowed to get closer to or farther from the object. As long as that difference is small, you can build the object into a skybox without making things look bad.

If that difference is large, that objects should probably not be rendered as part of the skybox (or you will have to accept the distortion). I can't think of a way to mathematically correct for this problem and keep to a "skybox" design.

The problem is that the skybox will contain images of objects that are (in reality) different distances from the user (e.g. clouds and the sun), so no single correction factor would be right. You could create textured-quad proxies for the objects and adjust the size and position dynamically, but you would need to do that on a per-object basis. Then it isn't a simple skybox anymore.

EDIT: Hmm. A fixed skybox that follows the user around can't simulate viewing constellations from anywhere in the world -- if the skybox moves with the user, you would carry the southern sky to the northern hemisphere -- so you would definitely need a more sophisticated model.

A fixed skybox can only simulate the local surroundings, so you would need to restrict user movement to keep them from getting too close the the nearest elements in the skybox, or travel far enough around the earth to have a different sky (but that will pass many other closer objects like mountains).

Of course, you could update the skybox dynamically (perhaps with FBO-based rendering) to adjust for large changes in user position (or time-of-day changes, or cloud movement).