Skip to content

How to add a Sky to your Scene

Here is an example for how you add a static horizon (a background landscape and a sky) to a scene. Having a discernible horizon with a suitable landscape (or space, or ocean, or whatever) in the background makes scenes look more realistic than just a single-colored “sky” background.

Adding the Sky

Adding a sky is extremely easy using the com.jme3.util.SkyFactory.

getRootNode().attachChild(SkyFactory.createSky(getAssetManager(), "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap));

To add a sky you need to supply:

  1. The assetManager object to use

  2. A cube or sphere map texture of the sky

  3. Set the map type: SkyFactory.EnvMapType. In this instance, CubeMap.

Internally, the SkyFactory calls the following methods:

  1. sky.setQueueBucket(Bucket.Sky); makes certain the sky is rendered in the right order, behind everything else.

  2. sky.setCullHint(Spatial.CullHint.Never); makes certain that the sky is never culled.

  3. The SkyFactory uses the internal jME3 material definition Sky.j3md. This Material definition works with sphere and cube maps.

Creating the Textures

This example uses BrightSky.dds from the separate jme3-testdata module. Add the module or provide a compatible cube map at the same asset key.

How can you create sky textures?

  • There are many tools out there that generate cube and sphere maps.
    Examples for landscape texture generators are Terragen or Bryce.

  • The sky bucket makes the sky appear behind the scene: Everything in the sky bucket will always be infinitely far away behind everything else, and never intersect with your scene.
    Choose a texture resolution supported by the target device and appropriate for its memory and rendering budget.

  • A box or sphere map is the simplest solution. But you can use any Node as sky, even complex sets of geometries and quads with animated clouds, blinking stars, city skylines, etc.

  • JME3 supports cube maps in PNG, JPG, or (compressed) DDS format.

Box or Sphere?

  • If you have access to cube map textures, then use a SkyBox

  • SkyBox examples

  • If you have access to sphere map textures – specially projected sky images that fit inside a sphere – then you use a SkySphere or SkyDome.

  • SkySphere example

For more information on Skymap creation see: