This is a sky-box
This is a method to dynamically render the texture of a sky-box.
Be aware this operation is expensive. Many games render the sky-box beforehand and just load them when when needed.
Objects behind the sky-box are not visible (because sky-box blocks the view). The purpose of a sky-box is to hide the fact that the view is limited by “projecting” something else than an empty screen. The sky-box should be the most far away (visible) object.
Therefore objects behind the sky-box do not even need to be present (for render).
This method would make the sky-box way too close. You will not be able to keep the illusion if a 3D Scene. That is the reason why skyboxes typically surround the camera with a constant distance.
The idea of a skybox is that movement of the camera is hardly noticeable. This means when the camera moves through a village, the perspective to the surrounding mountains does not change that much that you as viewer will notice the difference.
This is different when moving fast and far e.g. via airplanes, cars. In such cases a fixed sky-box will not work very well.
You can change the sky-box when moving. But there are two major problems:
A) a switch can be noticeable (when there are too much changes to the perspective)
B) a switch can be expensive (when you want to render the textures)
There are ways to come around that issues:
- have a finer granularity of sky-boxes
- distract the player when changing the sky-box (e.g. switch when the camera is in a tunnel)
- dynamical interpolate sky-boxes (e.g. via transparency fading or texture mixing).
- (as mentioned) pre-rendered sky-boxes
- ? (when you find a method for fast render, you most-likely do not need the sky-box anymore )