Download
Creating a Skybox
Introduction
A simulated sky can be added to a scene using a "skybox" (Wikipedia). A skybox is a large standard cube surrounding the scene, with a sky image painted on each face. (Images are a lot easier and faster to render than 3D objects, and just as good for far-distant scenery.)
A skybox in the editor can be created using 2 different methods:
  • Using a Cube Texture: create a skybox mesh and assign a cube texture to it. This method allows to use a custom texture for the skybox.
  • Using the Sky Material: create a skybox mesh and assign a new Sky Material to it. Babylon.js provides a material used to render sky that is customizable so the sky can appear "alive".
Creating the Skybox mesh
To create a new skybox mesh, simply use the main toolbar Add -> Skybox Mesh or right-click the scene graph and select Add -> Skybox Mesh.
A Skybox mesh is a cube mesh set to have back faces visible, so it can be seen from the inside. By default, a Skybox will have no material assigned to it.
Using Cube Texture
The goal here is to create a new material that will be assigned on the newly created Skybox. Then, assign an existing Cube Texture to the material as an Environment Texture. The last step will be to edit the Cube Texture to use "Skybox" coordinates mode.
To save loading time and performances in the application you are building, the editor provides a way to convert .hdr textures to .env textures. The issue addressed with .env is the size and quality of IBL Environment Textures.
More information about .env environement textures here.
To convert a .hdr texture to .env, just right-click the .hdr file in the Assets Browser panel and select "Convert to .env". Once the Cube Texture is converted, it will appear as a .env file in the assets and can now be used as an Environment Texture.
Using Sky Material
The principle here is the same as the previous method, but instead of creating a new material that will receive a Cube Texture, let's just create a new Sky Material.
Once applied, the Sky Material can be edited on the fly to change the aspect of the Skybox.