Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a simple airplane game where I use skybox cube rendered using disabled depth test.
Very close to the bottom side of the skybox is my terrain model.

What bothers me is that the terrain is not connected to the skybox bottom. This is not visible while the plane flies low, but as it gets some altitude, the terrain looks smaller because of the perspective. Since the skybox center is always same as the camera position, the skybox moves with the plane, but the terrain goes into the distance.

Ok, I think you understand the problem. My question is how to fix it.
It's an airplane game so limiting max altitude is not possible. I thought about some way to stretch terrain to always cover whole bottom side of the skybox cube, but that doesn't feel right and I don't even know how would I calculate new terrain dimensions every frame.

Here are some screenshot of games where you can clearly see the problem:
(oops, I cannot post images yet)

share|improve this question
up vote 3 down vote accepted

The simplest and often used solution is to use fog far away, to hide the places you don't want to be seen. It's used more often than you may think ;)

share|improve this answer
The fog sounds OK, I guess I could tone it so it doesn't look like some scary horror fog, but rather a light mist in the distance. But what I am concerned about is performance. I tagged the question as OpenGL ES 2 which means no built-in fog. Wouldn't it be too computation heavy to render such fog? I think @marcks-thomas 's solution would give better performance, wouldn't it? – David Sep 7 '12 at 16:55
I didn't know that OGL ES doesn't have a fog :/. Marcks Thomas solution is good, but you'll still get the terrain edges and they will move on the screen with your altitude (terrain becomes smaller). – kolenda Sep 11 '12 at 7:55
I ended up moving far plane further away (at the cost of depth buffer precision) which covers the gap quite well. To make it perfect I also used very light fog (which can be done on ES, but is not built-in) to hide the smallest details. If I run in any more skybox issues then I'll probably just limit the max altitude. Anyway I'm marking your post as an answer, as it seems best for me. Although it is only a part-solution, it's probably the simplest way to go :) – David Sep 11 '12 at 8:32

The quick fix, which works for low altitudes, is simply to extend the skybox texture further down.

Of course, you also need to make sure that your terrain actually extends all the way to where the horizon would be from the player's viewpoint. Skybox or no skybox, having the terrain just suddenly cut off isn't going to look good.

The real problem, however, is that if the player can fly, you can no longer safely treat everything in the sky as being infinitely far away. Just as an obvious example, the player should presumably be able to fly through a cloud; that's not going to work too well if the clouds are just textures on a skybox.

Instead, my suggestion would be to render clouds as actual objects in the game; you can use tricks like billboarding to keep them simple, at least as long as the player doesn't fly too close to them, but they should still be actual objects with a real 3D position. Your skybox should be reserved for things that can be safely treated as being infinitely far away, even from an airplane, such as astronomical objects like the sun, the moon and the stars.

As for the blue color of clear daytime sky (and the red and orange of sunrises and sunsets), that's actually somewhat tricky. In reality, it's caused by sunlight scattering off the air all around you, and its hue does depend on altitude (among other things) — the higher you go, the darker the sky looks above you. You probably want to include as part of your skybox, but generate it dynamically based on a formula that takes altitude into account. For realistic high-altitude horizons, you'll also want to apply some distance fogging to your terrain (and other objects) to simulate aerial perspective (which is also caused by atmospheric scattering).

share|improve this answer
Bonus points for mentioning some basic problems with the use of a skybox in a flying game. – Marcks Thomas Sep 6 '12 at 15:31

You wouldn't stretch the ground. As you gain altitude, you can see more of the terrain as the horizon expands, but it also appears smaller. The terrain covers less of your 2D projection in the air than on the ground. The difference is where previously unseen parts of your skybox will appear, and they have to show up as skies.

If at any point the bottom face of the skybox is visible, which seems unlikely unless the box is centered above the camera or you're reaching absurd altitudes, then that side too should have a neat blue texture with clouds.

share|improve this answer

Make the terrain round. Then the last ring of polygons sepperate into a different object. The inner circle should use an opaque material, while the outer ring should use a transparent material (with same texture) but uses vert color alpha to fade away.

So, on the ring mesh, make the inner ring of vertices 100% opaque, and the outer ring 100% transparent. Extend the outer ring of vertices away for the desired amount of fading out.

Make sure the whole ground (the 2 objects) is much larger than what the player can move into so they can't reach that edge. That way, regardless of height, or distance it's always going to blend on the edges with the skybox. Just make sure your skybox bottom texture is quite close in color to your fog and all should be fine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.