BabylonJS/Babylon.js · error · Error

Atmosphere only supports one light source currently.

Error message

Atmosphere only supports one light source currently.

What it means

Atmosphere's physical sky model currently evaluates sun/sky lighting for exactly one light (typically the sun). The constructor validates the `lights` array and throws when it does not contain exactly one element, because the lighting pipeline and shader uniforms are hardcoded for a single light source.

Source

Thrown at packages/dev/addons/src/atmosphere/atmosphere.ts:687

        lights: DirectionalLight[],
        options?: IAtmosphereOptions
    ) {
        RegisterEngineUniformBuffer();
        RegisterEnginesExtensionsEngineRenderTarget();

        const engine = (this._engine = scene.getEngine());

        if (!engine.isWebGPU && engine.version < 2) {
            throw new Error(`Atmosphere is not supported on WebGL ${engine.version}.`);
        }

        this._physicalProperties = options?.physicalProperties ?? new AtmospherePhysicalProperties();
        this._physicalProperties.onChangedObservable.add(() => {
            this._transmittanceLut?.markDirty();
        });

        if (lights.length !== 1) {
            throw new Error("Atmosphere only supports one light source currently.");
        }
        this._lights = lights;

        this.depthTexture = options?.depthTexture ?? null;
        this._exposure = options?.exposure ?? 1.0;
        this._isLinearSpaceLight = options?.isLinearSpaceLight ?? false;
        this._isLinearSpaceComposition = options?.isLinearSpaceComposition ?? false;
        this._applyApproximateTransmittance = options?.applyApproximateTransmittance ?? true;
        this._aerialPerspectiveRadianceBias = options?.aerialPerspectiveRadianceBias ?? 0.0;
        this._aerialPerspectiveTransmittanceScale = options?.aerialPerspectiveTransmittanceScale ?? 1.0;
        this._aerialPerspectiveSaturation = options?.aerialPerspectiveSaturation ?? 1.0;
        this._aerialPerspectiveIntensity = options?.aerialPerspectiveIntensity ?? 1.0;
        this._diffuseSkyIrradianceDesaturationFactor = options?.diffuseSkyIrradianceDesaturationFactor ?? 0.5;
        this._diffuseSkyIrradianceIntensity = options?.diffuseSkyIrradianceIntensity ?? 1.0;
        this._additionalDiffuseSkyIrradianceIntensity = options?.additionalDiffuseSkyIrradianceIntensity ?? 0.01;
        this._multiScatteringIntensity = options?.multiScatteringIntensity ?? 1.0;
        this._minimumMultiScatteringIntensity = options?.minimumMultiScatteringIntensity ?? 0.000618;
        this._isSkyViewLutEnabled = options?.isSkyViewLutEnabled ?? true;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Pass exactly one light, typically the scene's directional (sun) light: `new Atmosphere(scene, [sunLight])`.
  2. If you need multiple light sources, create separate handling outside Atmosphere or use a different sky solution; Atmosphere supports only one light per instance.
  3. Filter/choose the light before constructing: pick the directional light from scene.lights instead of passing the whole array.

Example fix

// before
const atmosphere = new Atmosphere(scene, scene.lights); // may contain several lights
// after
const sun = scene.lights.find((l) => l.getTypeID() === BAB.Light.LIGHTTYPEID_DIRECTIONALLIGHT)!;
const atmosphere = new Atmosphere(scene, [sun]);
Defensive patterns

Strategy: validation

Validate before calling

const lightsForAtmosphere = scene.lights.filter((l) => l.getTypeID() === BABYLON.Light.LIGHTTYPEID_DIRECTIONALLIGHT).slice(0, 1);
if (lightsForAtmosphere.length !== 1) throw new Error("Need exactly one sun light for Atmosphere");

Type guard

const isSingleLight = (lights: BABYLON.Light[]): lights is [BABYLON.Light] => lights.length === 1;

Try / catch

try {
  atmosphere = new Atmosphere(scene, lights);
} catch (e) {
  if (String(e).includes("one light source")) {
    atmosphere = new Atmosphere(scene, [lights[0] ?? defaultSun]);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `new Atmosphere(scene, lights, options)` with an empty lights array (`[]`) or with more than one light (`length !== 1`), e.g. passing sun plus a moon or fill light.

Common situations: Passing `scene.lights` directly (a scene usually has multiple lights: hemispheric + directional), passing an empty array before lights are created, or attempting multi-light setups like sun + moon in the same Atmosphere instance.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/82ccd07308d366ab. Report an issue: GitHub.