The graphics device.
The size of the environment atlas the lighting is generated to. Higher values give sharper reflections on glossy surfaces, and a sharper sky of the scene for the cameras without the effect, such as the cameras rendering planar reflections. Defaults to 512.
The azimuth of the sun, in degrees - its compass direction. Defaults to 0.
The camera frame the effect is registered with, or null.
The brightness of the sunlight falling on the clouds. Defaults to 0.6.
The fraction of the sky covered by clouds, 0-1 range, from a clear sky to overcast. Defaults to 0.45.
The altitude of the cloud layer, in meters. Defaults to 2000.
The brightness of the moonlight on the clouds at night. The moonlight of the DynamicSkyEffect#light is usually much brighter than the moon, to keep the night scene readable - lit by it, the clouds would glow against the dark night sky. Defaults to 0.05.
The opacity of the clouds, 0-1 range. Defaults to 1.
The quality of the volumetric clouds, 0-1 range - the number of their steps through the cloud layer, from 24 to 64, and toward the light, from 1 to 4, and the fineness of the steps through a cloud. The cost grows about linearly, doubling from 0.5 to 1. Lower values give less defined edges of the clouds and a flatter shading. Defaults to 0.5.
The resolution the volumetric clouds render at, relative to the resolution of the scene, 0.25-1 range. The clouds are soft, so a reduced resolution saves most of their cost with little loss of detail. The sky blurs them over 3x3 of their texels as it reads them, smoothing the grain of their steps, so lower values also soften the clouds. Defaults to 0.5.
The distance in meters over which the cloud pattern repeats. Larger values give larger clouds. Defaults to 8000.
The softness of the clouds, 0.01-1 range. Lower values give dense clouds with crisp edges and deep shadows, higher values thin them into translucent, wispy clouds with softer shading. Defaults to 0.7.
The fraction of the sunlight the clouds block at the full coverage, dimming the DynamicSkyEffect#light. Defaults to 0.6.
The thickness of the layer of the volumetric clouds, in meters, above their DynamicSkyEffect#cloudHeight. Defaults to 2500.
The type of the clouds of the sky, CLOUDTYPE_NONE, CLOUDTYPE_FLAT or CLOUDTYPE_VOLUMETRIC. Defaults to CLOUDTYPE_NONE.
The graphics device.
The elevation of the sun above the horizon, in degrees. Negative values place the sun below the horizon, which gives the night sky. Defaults to 25.
Whether the effect is enabled. An effect can additionally disable itself from its own parameters, see CameraFrameEffect#active.
The directional light kept in sync with the sun - its direction, color and intensity. By day it shines from the sun, at DynamicSkyEffect#sunIntensity, dimmed by the clouds, and at night it fades to the moonlight, see DynamicSkyEffect#moonIntensity. Defaults to null.
Whether the effect generates the lighting of the scene from its sky - the environment atlas lighting the materials, assigned to Scene#envAtlas. Only one effect should do so, the one of the main camera. The lighting is generated when the effect is first used, and again when the sun moves by DynamicSkyEffect#lightingThreshold, when a setting of the sky changes by more than a percent, when the clouds drift by DynamicSkyEffect#lightingCloudThreshold, and when DynamicSkyEffect#bakeLighting is called. The clouds are a still image in the lighting, and the sun disc is left out of it, as the DynamicSkyEffect#light carries the light of the sun. Defaults to true.
The distance the clouds drift by, as a fraction of the DynamicSkyEffect#cloudSize, before the lighting is generated again, so the clouds in it follow the clouds of the sky. A value of 0 disables it, and the drift of the clouds does not generate the lighting again. Defaults to 0.
Whether the lighting blends from its previous update to its latest one, instead of changing at once. While the sky changes gradually, such as with an animated time of day, each update blends in over the time since the previous one, up to a second, so the lighting follows the sky smoothly, about one update behind it. Without it, the lighting steps at each update, which shows as flicker in the reflections of a quickly changing sky on glossy surfaces, such as water. Sudden changes, such as a jump of the time of day, and DynamicSkyEffect#bakeLighting, still apply at once. It costs two more environment atlases of memory, and a small pass each frame while the lighting blends, so enable it only when the sky changes continuously. Defaults to false.
The resolution of the sky the lighting is generated from, the size of the faces of a cubemap, in texels. The sky is filtered down from it to the environment atlas, so it should be well above the resolution of the atlas: at lower values, the detail of the clouds aliases, and their reflections flicker on each update of the lighting as the clouds drift. Defaults to 256.
The angle the sun moves by, in degrees, before the lighting is generated again - keeping the cost of a day and night cycle down. Defaults to 0.5.
The brightness of the sky, relative to the light of the sun. At 1, the sky lights the scene with about a tenth of the light of the sun, as a clear sky does, at any elevation of the sun: the blue sky and the ground lit by the sun are then of a similar brightness, so a single exposure suits both. Lower values give a deeper sky, higher values a brighter one, and a brighter ambient light of the scene. Defaults to 1.
The amount of the Mie (aerosol) scattering, 0-0.1 range, setting the brightness of the glow around the sun. Defaults to 0.005.
The directional anisotropy of the Mie scattering, 0-1 range, setting how tightly the glow hugs the sun. Defaults to 0.8.
The color of the moonlight, and of the moon disc. Defaults to a pale blue.
The direction toward the moon, in the world space, turned by the DynamicSkyEffect#rotation of the sky. It does not need to be normalized. Defaults to a direction high in the sky.
The brightness of the moon disc in the night sky. Defaults to 3.
The intensity of the DynamicSkyEffect#light at night - the moonlight, a dim cool light from the direction of the moon. Defaults to 1.
The angular radius of the moon disc, in degrees. Defaults to 0.6.
The brightness of the night sky. Defaults to 0.052.
The color of the night sky. Defaults to a deep blue.
The amount of the Rayleigh scattering, 0-4 range, setting the blueness of the sky. Defaults to 1.5.
The rotation of the whole sky around the vertical axis, in degrees. It is added to the azimuth of the sun, so the sky, the sun and the moon turn together, along with the light and the shadows it casts. Defaults to 0.
The brightness of the stars. A value of 0 disables them. Defaults to 0.05.
The density of the stars, 0-1 range - the fraction of the cells of the sky holding a star. Defaults to 0.8.
The scale of the size of the stars. Defaults to 0.5.
The intensity of the light of the sun: of the DynamicSkyEffect#light with the sun above the horizon, and of the sunlit clouds. The sky scales with it too, see DynamicSkyEffect#luminance, so it sets the brightness of the whole day, to match the exposure of the camera. Defaults to 2, a sunny day at an exposure of 1.
The haziness of the atmosphere, 1-20 range. Higher values give a milkier sky and a larger glow around the sun. Defaults to 2.
The strength of the warm glow at the horizon while the sun is just below it. Defaults to 0.52.
The direction the clouds drift toward, in degrees around the vertical axis. Defaults to 45.
The speed the clouds drift with, in meters per second. Defaults to 10.
Gets whether the effect contributes to the frame. Defaults to CameraFrameEffect#enabled. Effects gated on a parameter - a zero intensity, a missing texture - override this.
Gets the scale the effect applies to the exposure of the camera this frame, multiplying the exposure of the scene, or of the physical camera with physical units - for effects adapting the exposure to what the camera sees. Read every frame while the effect takes part, after CameraFrameEffect#frameUpdate; the camera frame applies the product of the scales of the effects taking part, and the camera renders with its own exposure again once none does. Defaults to 1.
// an effect brightening the image by one stop
get cameraExposureScale() {
return 2;
}
Gets the name the compose chunk can be overridden under in ShaderChunks, the same
way as the built-in chunks. Derived from the id as compose<Id>PS unless given.
Gets the names of the debug views the chunk provides.
Gets the define set on the compose shader while the effect is active: the id in upper snake
case, colorEnhance giving COLOR_ENHANCE.
Gets the name of the function the composition calls at the effect's slot. Derived from the
id as apply<Id> unless given. The signature depends on the slot: colour slots take
(vec3 color, vec2 uv) and return the colour, COMPOSESLOT_SCENE takes and returns a
vec4.
Gets the GLSL source of the compose chunk, or null when the effect has none.
Gets the identifier of the effect.
Gets the frame resources the effect needs, the FRAMERESOURCE_* constants - for its passes, or for its compose chunk, such as the scene depth. The camera frame provides them while the effect is active. Requirements which depend on the device are computed when constructing the effect; override this as a getter when they depend on a parameter, and the camera frame provides what it returns from the next CameraFrame#update.
Gets the compose slot the entry function is called at, or null for an effect that does not take part in the composition.
Gets the WGSL source of the compose chunk, or null when the effect has none.
Requests the lighting of the scene to be generated from the sky again, before the next frame renders. Use it when the lighting should follow a change it does not regenerate for on its own, such as the drift of the clouds with DynamicSkyEffect#lightingCloudThreshold disabled.
Destroys the effect, removing it from its camera frame if it is still registered and
releasing everything it owns, the passes it created included. Subclasses which create
resources in their constructor release them in an override, calling super.destroy(). The
removal takes effect for the frames rendered after the next CameraFrame#update, which
is due before the next frame renders.
The values of this frame.
Returns the compose chunk source for a shader language.
SHADERLANGUAGE_GLSL or SHADERLANGUAGE_WGSL.
The source, or null when the effect has no chunk.
Sets a define on the compose shader. The define persists until changed, so fixed defines can be set once in the constructor and those depending on the parameters from CameraFrameEffect#update. A value of false, null or undefined removes it. Changing a define rebuilds the compose shader.
The define name.
The value.
Sets the value of a uniform the effect's shader chunk reads. Like a material parameter, the value is stored by reference, so an array or a texture can be updated in place. Set the values in CameraFrameEffect#update, or in CameraFrameEffect#frameUpdate for a value which changes every frame.
The name of the uniform, as declared in the chunk.
The value.
Applies the effect's parameters. Called by CameraFrame#update while the effect is active: set the uniform values with CameraFrameEffect#setUniform here, and the defines which depend on the parameters. Everything it sets is what the frames rendered until the next update use.
The dynamic sky effect: renders the sky of the camera - a day sky of an analytic atmosphere, lit by the sun, a night sky of stars and the moon, and optionally clouds drifting with the wind - in place of the sky of the scene. The time of day is set by the position of the sun, see DynamicSkyEffect#azimuth and DynamicSkyEffect#elevation, and the effect can keep a directional light in sync with it, see DynamicSkyEffect#light.
The sky has no clouds by default, see DynamicSkyEffect#cloudType. They are a single flat layer of noise (CLOUDTYPE_FLAT), or volumetric clouds ray marched through a layer of 3D noise (CLOUDTYPE_VOLUMETRIC). The volumetric clouds are the expensive part of the sky, and render to a texture of their own, at a reduced resolution by default, see DynamicSkyEffect#cloudResolution. Their noise is generated on the CPU when the clouds are first used.
The effect also generates the lighting of the scene from its sky: the environment atlas lighting the materials, assigned to Scene#envAtlas, see DynamicSkyEffect#lighting. The cameras without the effect, such as the cameras rendering planar reflections, render the sky of the scene from that environment atlas - a still image of this sky. The effect is not supported in XR.
The sky does not work together with the volumetric fog of the camera frame, CameraFrame#volumetricFog: the clouds cast no shadows into the fog, and the fog is not lit by the light of the sky.
The effect is not part of a camera frame by default - construct it and add it to the camera frame of a camera:
Like all effects, its settings apply on the next CameraFrame#update, which a day and night cycle moving the sun calls every frame. The clouds drift with the time of the application.