The sky material allows to create dynamic and texture free effects for skyboxes.
The challenge for skyboxes is to reproduce and configure the sky taking care of the atmosphere state. In other words, for example, determine how the light (from sun) is scattered by particles.
A Playground example can be found here: Animate the sky -
Just press the following keys:
Simply create a skybox and assign a new instance of the Sky Material:
var skyMaterial = new BABYLON.SkyMaterial("skyMaterial", scene); skyMaterial.backFaceCulling = false; var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene); skybox.material = skyMaterial;
The aspect of the sky can be customized, including the day/night time. The properties are:
skyMaterial.turbidity = 1; // Represents the amount (scattering) of haze as opposed to molecules in atmosphere
skyMaterial.luminance = 1; // Controls the overall luminance of sky in interval ]0, 1,190[
// Control the planet's orientation over the sun skyMaterial.inclination = 0.5; // The solar inclination, related to the solar azimuth in interval [0, 1] skyMaterial.azimuth = 0.25; // The solar azimuth in interval [0, 1]
Otherwise, if you want to configure the sun position with a BABYLON.Vector3, you can set:
// Manually set the sun position skyMaterial.useSunPosition = true; // Do not set sun position from azimuth and inclination skyMaterial.sunPosition = new BABYLON.Vector3(0, 100, 0);
skyMaterial.rayleigh = 2; // Represents the sky appearance (globally)
// Mie scattering (from [Gustav Mie](https://en.wikipedia.org/wiki/Gustav_Mie)) // Related to the haze particles in atmosphere // The amount of haze particles following the Mie scattering theory skyMaterial.mieDirectionalG = 0.8; skyMaterial.mieCoefficient = 0.005; // The mieCoefficient in interval [0, 0.1], affects the property skyMaterial.mieDirectionalG
As a common technique, it would be useful to use the sky material result to reflect the environment. For example, using a PBR material.
The technique consits on creating a reflection probe (which is a cube texture) and render the sky mesh with the sky material assigned to it. As an example, a playground is available here: https://www.babylonjs-playground.com/#4R1H1U -