CesiumJS Atmosphere and Lighting Syntax
Overview
CesiumJS renders the sky, the air, and the light as distinct objects that all
hang off Scene. The blue halo seen AROUND the globe from space is
scene.skyAtmosphere (a SkyAtmosphere). The hazy air rendered ON the globe
surface near the horizon is the GROUND atmosphere, controlled on scene.globe
(a Globe). The star field is scene.skyBox, the celestial bodies are
scene.sun and scene.moon, distance haze is scene.fog, and the shading
light for models and tiles is scene.light.
Core principle: sky atmosphere and ground atmosphere are SEPARATE objects with
separately-stored but identically-named properties. Tuning one NEVER changes
the other. This single fact prevents most atmosphere bugs.
This skill is technology-specific: CesiumJS 1.124+, WebGL2 only.
When to Use This Skill
- The sky is black instead of blue, or shows no atmosphere.
- The globe looks too dark, or has no day-night terminator.
- Tuning an atmosphere property had no visible effect.
- Adding or removing the star field, sun, or moon.
- Setting a fixed light direction instead of the moving sun.
- Distant terrain washes out, or you want to disable haze.
- Atmosphere looks wrong in 2D or Columbus view.
Quick Reference: Atmosphere and Lighting Objects
| Object |
Member |
What it renders |
SkyAtmosphere |
scene.skyAtmosphere |
blue halo and sky color around the globe (3D only) |
Globe |
scene.globe |
ground atmosphere haze and terrain day-night lighting |
SkyBox |
scene.skyBox |
the star field behind the globe |
Sun |
scene.sun |
the sun disc and lens flare |
Moon |
scene.moon |
the moon disc |
Fog |
scene.fog |
distance haze over terrain |
Light |
scene.light |
the shading light for models, tiles, primitives |
A Viewer and a CesiumWidget create skyAtmosphere, skyBox, sun, and
moon automatically. They are present on viewer.scene without extra
construction.
Sky Atmosphere vs Ground Atmosphere
digraph atmosphere_choice {
"Which atmosphere effect?" [shape=diamond];
"Halo and sky color seen from space" [shape=box];
"Haze on the globe surface near the horizon" [shape=box];
"scene.skyAtmosphere : a SkyAtmosphere" [shape=box];
"scene.globe : showGroundAtmosphere plus atmosphere props" [shape=box];
"Which atmosphere effect?" -> "Halo and sky color seen from space";
"Which atmosphere effect?" -> "Haze on the globe surface near the horizon";
"Halo and sky color seen from space" -> "scene.skyAtmosphere : a SkyAtmosphere";
"Haze on the globe surface near the horizon" -> "scene.globe : showGroundAtmosphere plus atmosphere props";
}
Both objects expose atmosphereLightIntensity, atmosphereRayleighCoefficient,
atmosphereMieCoefficient, atmosphereRayleighScaleHeight,
atmosphereMieScaleHeight, and atmosphereMieAnisotropy. The names match; the
objects do not. ALWAYS set the property on the object you mean. NEVER expect
globe.atmosphereLightIntensity to change the halo, or
skyAtmosphere.atmosphereLightIntensity to change the surface haze.
The defaults differ, which confirms they are separate:
SkyAtmosphere.atmosphereLightIntensity is 50.0,
Globe.atmosphereLightIntensity is 10.0.
Sky Atmosphere
scene.skyAtmosphere is a SkyAtmosphere. It renders ONLY in 3D scene mode and
fades out when morphing to 2D or Columbus view.
const sky = viewer.scene.skyAtmosphere;
sky.show = true; // default true
sky.hueShift = 0.0; // -1.0 to 1.0
sky.saturationShift = 0.0; // -1.0 to 1.0
sky.brightnessShift = 0.0; // -1.0 to 1.0
sky.atmosphereLightIntensity = 50.0;
| Property |
Default |
Effect |
show |
true |
renders the halo and sky |
hueShift |
0.0 |
rotates sky hue |
saturationShift |
0.0 |
shifts sky saturation |
brightnessShift |
0.0 |
shifts sky brightness |
atmosphereLightIntensity |
50.0 |
brightness of scattered light |
perFragmentAtmosphere |
false |
per-fragment instead of per-vertex shading |
ALWAYS toggle visibility with skyAtmosphere.show; it is the supported on-off
switch. Setting show = false yields pure black space.
Ground Atmosphere and Globe Lighting
scene.globe carries the ground atmosphere haze and the terrain lighting.
const globe = viewer.scene.globe;
globe.showGroundAtmosphere = true; // haze on the surface near the horizon
globe.enableLighting = true; // sun-based day-night terrain shading
globe.atmosphereLightIntensity = 10.0;
| Property |
Default |
Effect |
showGroundAtmosphere |
true on WGS84 |
surface haze near the horizon |
enableLighting |
false |
day-night terminator on terrain |
dynamicAtmosphereLighting |
true |
atmosphere follows the scene light |
dynamicAtmosphereLightingFromSun |
false |
atmosphere follows the real sun instead |
atmosphereLightIntensity |
10.0 |
brightness of the ground atmosphere |
enableLighting defaults to false, so by default the whole globe is lit
evenly with no night side. ALWAYS set globe.enableLighting = true to get a
day-night terminator.
Sky Box, Sun, and Moon
viewer.scene.skyBox.show = true; // star field
viewer.scene.sun.show = true; // sun disc and flare
viewer.scene.moon.show = true; // moon disc
SkyBox is the star field. A custom star field uses
new Cesium.SkyBox({ sources: { positiveX, negativeX, positiveY, negativeY, positiveZ, negativeZ } }) with six cube-map face images.
Sun has show (default true) and glowFactor (default 1.0; 0 shows
the disc with no flare).
Moon has show (default true), textureUrl, ellipsoid (default
Ellipsoid.MOON), and onlySunLighting (default true).
scene.sunBloom (default true) adds a bloom post-process around the sun.
Scene Light: SunLight vs DirectionalLight
scene.light is the Light that shades models, 3D Tiles, and primitives. Two
implementations exist.
| Class |
Behavior |
Default intensity |
SunLight |
follows the real sun position over time |
2.0 |
DirectionalLight |
fixed direction, never moves |
1.0 |
scene.light defaults to a SunLight. ALWAYS use a DirectionalLight when the
shading must stay constant regardless of the clock.
viewer.scene.light = new Cesium.DirectionalLight({
direction: Cesium.Cartesian3.normalize(
new Cesium.Cartesian3(0.5, -0.5, -0.7),
new Cesium.Cartesian3()
),
intensity: 2.0,
});
The direction is REQUIRED and must NEVER be zero-length; a zero-length vector
throws a DeveloperError.
Fog
scene.fog is a Fog. It fades distant terrain into haze and lets CesiumJS
lower the detail of far tiles for performance.
| Property |
Default |
Effect |
enabled |
true |
fog on or off |
density |
0.0006 |
thickness of the fog |
minimumBrightness |
0.03 |
darkest the fog color may get |
screenSpaceErrorFactor |
2.0 |
how much far-tile detail drops in fog |
NEVER disable fog purely for visual clarity without measuring performance;
fog also reduces the tile load for distant terrain.
Common Mistakes
| Mistake |
Fix |
globe.atmosphereLightIntensity to change the halo |
Set it on scene.skyAtmosphere instead |
| Sky atmosphere tuned in 2D or Columbus view |
SkyAtmosphere is 3D-only; it fades out otherwise |
| Globe evenly lit, no night side |
Set globe.enableLighting = true |
| Sky is black, expected blue |
scene.skyAtmosphere.show is false, or the scene is in 2D |
new DirectionalLight({}) with no direction |
direction is required and non-zero |
| Disabled fog, distant terrain slow |
Fog lowers far-tile detail; re-enable it |
Full root-cause analysis is in references/anti-patterns.md.
Reference Files
references/methods.md : verified properties and defaults for SkyAtmosphere,
Globe, SkyBox, Sun, Moon, Fog, SunLight, and DirectionalLight.
references/examples.md : runnable snippets for black space, day-night
lighting, custom star fields, fixed lights, and fog tuning.
references/anti-patterns.md : atmosphere and lighting failure modes, each
with symptom, root cause, prevention, and recovery.
Related Skills
cesium-core-architecture : the Scene containment hierarchy these objects sit in.
cesium-syntax-viewer : Viewer and CesiumWidget construction.
cesium-syntax-materials : CustomShader lighting models and post-process stages.
cesium-syntax-time : the Clock that drives SunLight and dynamic atmosphere.
cesium-core-performance : requestRenderMode and fog-based detail tuning.
1---2name: cesium-syntax-atmosphere3description: Use when configuring the CesiumJS sky, atmosphere, lighting, sun, moon, star field, or fog, and the sky renders black, the globe looks too dark or evenly lit, an atmosphere property has no visible effect, or the atmosphere is missing in 2D. Prevents the wrong-atmosphere-object mistake (sky atmosphere and ground atmosphere are separate objects with identically named properties), the disabled-lighting mistake (Globe.enableLighting defaults to false so there is no day-night terminator), the 3D-only mistake (SkyAtmosphere fades out in 2D), and the zero-length DirectionalLight error. Covers SkyAtmosphere, the Globe ground atmosphere, SkyBox, Sun, Moon, Fog, and the scene Light. Keywords: CesiumJS atmosphere, SkyAtmosphere, skyAtmosphere, skyBox, scene.sun, scene.moon, Fog, scene.light, SunLight, DirectionalLight, enableLighting, showGroundAtmosphere, atmosphereLightIntensity, hueShift, brightnessShift, sky black, no atmosphere, globe too dark, no day night terminator, sky is dark, no stars, atmosphere not showing,4license: MIT5---67# CesiumJS Atmosphere and Lighting Syntax89## Overview1011CesiumJS renders the sky, the air, and the light as distinct objects that all12hang off `Scene`. The blue halo seen AROUND the globe from space is13`scene.skyAtmosphere` (a `SkyAtmosphere`). The hazy air rendered ON the globe14surface near the horizon is the GROUND atmosphere, controlled on `scene.globe`15(a `Globe`). The star field is `scene.skyBox`, the celestial bodies are16`scene.sun` and `scene.moon`, distance haze is `scene.fog`, and the shading17light for models and tiles is `scene.light`.1819Core principle: sky atmosphere and ground atmosphere are SEPARATE objects with20separately-stored but identically-named properties. Tuning one NEVER changes21the other. This single fact prevents most atmosphere bugs.2223This skill is technology-specific: CesiumJS 1.124+, WebGL2 only.2425## When to Use This Skill2627- The sky is black instead of blue, or shows no atmosphere.28- The globe looks too dark, or has no day-night terminator.29- Tuning an atmosphere property had no visible effect.30- Adding or removing the star field, sun, or moon.31- Setting a fixed light direction instead of the moving sun.32- Distant terrain washes out, or you want to disable haze.33- Atmosphere looks wrong in 2D or Columbus view.3435## Quick Reference: Atmosphere and Lighting Objects3637| Object | Member | What it renders |38|--------|--------|-----------------|39| `SkyAtmosphere` | `scene.skyAtmosphere` | blue halo and sky color around the globe (3D only) |40| `Globe` | `scene.globe` | ground atmosphere haze and terrain day-night lighting |41| `SkyBox` | `scene.skyBox` | the star field behind the globe |42| `Sun` | `scene.sun` | the sun disc and lens flare |43| `Moon` | `scene.moon` | the moon disc |44| `Fog` | `scene.fog` | distance haze over terrain |45| `Light` | `scene.light` | the shading light for models, tiles, primitives |4647A `Viewer` and a `CesiumWidget` create `skyAtmosphere`, `skyBox`, `sun`, and48`moon` automatically. They are present on `viewer.scene` without extra49construction.5051## Sky Atmosphere vs Ground Atmosphere5253```dot54digraph atmosphere_choice {55 "Which atmosphere effect?" [shape=diamond];56 "Halo and sky color seen from space" [shape=box];57 "Haze on the globe surface near the horizon" [shape=box];58 "scene.skyAtmosphere : a SkyAtmosphere" [shape=box];59 "scene.globe : showGroundAtmosphere plus atmosphere props" [shape=box];6061 "Which atmosphere effect?" -> "Halo and sky color seen from space";62 "Which atmosphere effect?" -> "Haze on the globe surface near the horizon";63 "Halo and sky color seen from space" -> "scene.skyAtmosphere : a SkyAtmosphere";64 "Haze on the globe surface near the horizon" -> "scene.globe : showGroundAtmosphere plus atmosphere props";65}66```6768Both objects expose `atmosphereLightIntensity`, `atmosphereRayleighCoefficient`,69`atmosphereMieCoefficient`, `atmosphereRayleighScaleHeight`,70`atmosphereMieScaleHeight`, and `atmosphereMieAnisotropy`. The names match; the71objects do not. ALWAYS set the property on the object you mean. NEVER expect72`globe.atmosphereLightIntensity` to change the halo, or73`skyAtmosphere.atmosphereLightIntensity` to change the surface haze.7475The defaults differ, which confirms they are separate:76`SkyAtmosphere.atmosphereLightIntensity` is `50.0`,77`Globe.atmosphereLightIntensity` is `10.0`.7879## Sky Atmosphere8081`scene.skyAtmosphere` is a `SkyAtmosphere`. It renders ONLY in 3D scene mode and82fades out when morphing to 2D or Columbus view.8384```js85const sky = viewer.scene.skyAtmosphere;86sky.show = true; // default true87sky.hueShift = 0.0; // -1.0 to 1.088sky.saturationShift = 0.0; // -1.0 to 1.089sky.brightnessShift = 0.0; // -1.0 to 1.090sky.atmosphereLightIntensity = 50.0;91```9293| Property | Default | Effect |94|----------|---------|--------|95| `show` | `true` | renders the halo and sky |96| `hueShift` | `0.0` | rotates sky hue |97| `saturationShift` | `0.0` | shifts sky saturation |98| `brightnessShift` | `0.0` | shifts sky brightness |99| `atmosphereLightIntensity` | `50.0` | brightness of scattered light |100| `perFragmentAtmosphere` | `false` | per-fragment instead of per-vertex shading |101102ALWAYS toggle visibility with `skyAtmosphere.show`; it is the supported on-off103switch. Setting `show = false` yields pure black space.104105## Ground Atmosphere and Globe Lighting106107`scene.globe` carries the ground atmosphere haze and the terrain lighting.108109```js110const globe = viewer.scene.globe;111globe.showGroundAtmosphere = true; // haze on the surface near the horizon112globe.enableLighting = true; // sun-based day-night terrain shading113globe.atmosphereLightIntensity = 10.0;114```115116| Property | Default | Effect |117|----------|---------|--------|118| `showGroundAtmosphere` | `true` on WGS84 | surface haze near the horizon |119| `enableLighting` | `false` | day-night terminator on terrain |120| `dynamicAtmosphereLighting` | `true` | atmosphere follows the scene light |121| `dynamicAtmosphereLightingFromSun` | `false` | atmosphere follows the real sun instead |122| `atmosphereLightIntensity` | `10.0` | brightness of the ground atmosphere |123124`enableLighting` defaults to `false`, so by default the whole globe is lit125evenly with no night side. ALWAYS set `globe.enableLighting = true` to get a126day-night terminator.127128## Sky Box, Sun, and Moon129130```js131viewer.scene.skyBox.show = true; // star field132viewer.scene.sun.show = true; // sun disc and flare133viewer.scene.moon.show = true; // moon disc134```135136- `SkyBox` is the star field. A custom star field uses137 `new Cesium.SkyBox({ sources: { positiveX, negativeX, positiveY, negativeY,138 positiveZ, negativeZ } })` with six cube-map face images.139- `Sun` has `show` (default `true`) and `glowFactor` (default `1.0`; `0` shows140 the disc with no flare).141- `Moon` has `show` (default `true`), `textureUrl`, `ellipsoid` (default142 `Ellipsoid.MOON`), and `onlySunLighting` (default `true`).143- `scene.sunBloom` (default `true`) adds a bloom post-process around the sun.144145## Scene Light: SunLight vs DirectionalLight146147`scene.light` is the `Light` that shades models, 3D Tiles, and primitives. Two148implementations exist.149150| Class | Behavior | Default intensity |151|-------|----------|-------------------|152| `SunLight` | follows the real sun position over time | `2.0` |153| `DirectionalLight` | fixed direction, never moves | `1.0` |154155`scene.light` defaults to a `SunLight`. ALWAYS use a `DirectionalLight` when the156shading must stay constant regardless of the clock.157158```js159viewer.scene.light = new Cesium.DirectionalLight({160 direction: Cesium.Cartesian3.normalize(161 new Cesium.Cartesian3(0.5, -0.5, -0.7),162 new Cesium.Cartesian3()163 ),164 intensity: 2.0,165});166```167168The `direction` is REQUIRED and must NEVER be zero-length; a zero-length vector169throws a `DeveloperError`.170171## Fog172173`scene.fog` is a `Fog`. It fades distant terrain into haze and lets CesiumJS174lower the detail of far tiles for performance.175176| Property | Default | Effect |177|----------|---------|--------|178| `enabled` | `true` | fog on or off |179| `density` | `0.0006` | thickness of the fog |180| `minimumBrightness` | `0.03` | darkest the fog color may get |181| `screenSpaceErrorFactor` | `2.0` | how much far-tile detail drops in fog |182183NEVER disable `fog` purely for visual clarity without measuring performance;184fog also reduces the tile load for distant terrain.185186## Common Mistakes187188| Mistake | Fix |189|---------|-----|190| `globe.atmosphereLightIntensity` to change the halo | Set it on `scene.skyAtmosphere` instead |191| Sky atmosphere tuned in 2D or Columbus view | `SkyAtmosphere` is 3D-only; it fades out otherwise |192| Globe evenly lit, no night side | Set `globe.enableLighting = true` |193| Sky is black, expected blue | `scene.skyAtmosphere.show` is `false`, or the scene is in 2D |194| `new DirectionalLight({})` with no direction | `direction` is required and non-zero |195| Disabled fog, distant terrain slow | Fog lowers far-tile detail; re-enable it |196197Full root-cause analysis is in `references/anti-patterns.md`.198199## Reference Files200201- `references/methods.md` : verified properties and defaults for `SkyAtmosphere`,202 `Globe`, `SkyBox`, `Sun`, `Moon`, `Fog`, `SunLight`, and `DirectionalLight`.203- `references/examples.md` : runnable snippets for black space, day-night204 lighting, custom star fields, fixed lights, and fog tuning.205- `references/anti-patterns.md` : atmosphere and lighting failure modes, each206 with symptom, root cause, prevention, and recovery.207208## Related Skills209210- `cesium-core-architecture` : the `Scene` containment hierarchy these objects sit in.211- `cesium-syntax-viewer` : `Viewer` and `CesiumWidget` construction.212- `cesium-syntax-materials` : `CustomShader` lighting models and post-process stages.213- `cesium-syntax-time` : the `Clock` that drives `SunLight` and dynamic atmosphere.214- `cesium-core-performance` : `requestRenderMode` and fog-based detail tuning.