Skip to content

Sky and environment

A sky provides a visual background for a 3D scene. An HDR environment can also provide light and reflections, but adding a sky alone does not create a light probe: tag it for an environment probe when using image-based lighting.

An equirectangular panorama is a convenient starting point:

Spatial sky = SkyFactory.createSky(assetManager,
        "Textures/Sky/studio.hdr", SkyFactory.EnvMapType.EquirectMap);
rootNode.attachChild(sky);
EnvironmentProbeControl probe = new EnvironmentProbeControl(assetManager, 256);
rootNode.addControl(probe);
probe.tag(sky);

Place your own HDR image at that asset path and ensure your target includes an image loader that supports HDR. A cube map can also be used with SkyFactory.EnvMapType.CubeMap. PNG and JPEG images can provide a visible background, but cannot represent the same high dynamic range as an HDR environment. Check the license of any sky texture before redistribution. HDR images can benefit from tone mapping; tune your settings rather than assuming the background and illumination will match an authoring tool automatically.

Skyboxes and sky spheres

SkyFactory supports different environment-map projections. For a cube map, select SkyFactory.EnvMapType.CubeMap; for an equirectangular panorama, use EquirectMap as in the example above. Choose a map with enough resolution for your target devices without exceeding their texture and memory limits.

The factory places the sky in the Sky render bucket and disables culling so it remains a background as the camera moves. A sky can also be built from your own scene geometry, for example to add animated clouds or stars. For a simple cube-map example, see How to add a sky to your scene.

To create an environment yourself, see How to create free skymaps, or explore the asset resources.

See SkyFactory and the PBR guide.