A very large percentage of games use textures to fake 'stuff' on or over the horizon. Distant mountains, buildings, clouds, hills, stars, nebula, sun, moon, etc, can all be painted into textures rather than rendered with actual geometry.
However, there are several geometries and mapping methods that can be used, each with their own advantages and disadvantages. This application showcases 3 types of environment geometry: sphere, cube and dome. Which one you choose depends on your requirements and how it will be used:
- Advantages: 1 texture, 1 draw call, only 1 seam, full 360 degree coverage
- Disadvantages: texture singularity at poles
- Example usage: racing game (no looking directly up)
- Advantages: minimal texture distortion, full 360 degree coverage, only 12 triangles
- Disadvantages: 6 textures, 6 draw calls, more seams
- Example usage: space battle game (full rotation)
- Advantages: 1 texture, 1 draw call, 0 seams, minimal texture distortion
- Disadvantages: 50% coverage
- Example usage: first-person shooter with fairly flat terrain
They all use vertex buffer objects and triangle strips for greatest speed. The code is clear, concise and optimized.
TIP: It is SOMETIMES a good idea to render your sky last. This is because the other geometry will have written to the depth buffer, and a large portion of the sky pixels will fail the z test and never be drawn. If you render the sky first, they will be drawn unnecessarily. Of course, this only works if you have no transparency in the scene.
Note: The example program uses freeglut for window creation but the Sky Geometry components themselves do not, so they are very portable.