BabylonJS/Babylon.js · error · Error

FrameGraphCascadedShadowGeneratorTask ${this.name}: light, o

Error message

FrameGraphCascadedShadowGeneratorTask ${this.name}: light, objectList and camera are required

What it means

FrameGraphCascadedShadowGeneratorTask.record() throws when the required inputs light, objectList, or camera are undefined. Like all frame graph tasks, the CSM shadow generator needs its light source, the list of shadow-casting/receiving objects, and the camera bound before the frame graph is recorded.

Source

Thrown at packages/dev/core/src/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.ts:305

            shadowGenerator.stabilizeCascades = this._stabilizeCascades;
            shadowGenerator.lambda = this._lambda;
            shadowGenerator.cascadeBlendPercentage = this._cascadeBlendPercentage;
            shadowGenerator.depthClamp = this._depthClamp;
            shadowGenerator.shadowMaxZ = this._shadowMaxZ;

            return true;
        }

        return false;
    }

    public override getClassName(): string {
        return "FrameGraphCascadedShadowGeneratorTask";
    }

    public override record() {
        if (this.light === undefined || this.objectList === undefined || this.camera === undefined) {
            throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: light, objectList and camera are required`);
        }

        if (this.depthTexture !== undefined) {
            const depthTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.depthTexture);

            const size = !depthTextureCreationOptions.sizeIsPercentage
                ? textureSizeIsObject(depthTextureCreationOptions.size)
                    ? depthTextureCreationOptions.size
                    : { width: depthTextureCreationOptions.size, height: depthTextureCreationOptions.size }
                : this._frameGraph.textureManager.getAbsoluteDimensions(depthTextureCreationOptions.size);

            const width = size.width;
            const height = size.height;

            depthTextureCreationOptions.sizeIsPercentage = false;
            depthTextureCreationOptions.options.formats = [Constants.TEXTUREFORMAT_RG];
            depthTextureCreationOptions.options.samples = 1;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Assign all three before record(): task.light, task.objectList, and task.camera.
  2. Create the object list via frameGraph.createObjectList with the meshes that should cast/receive shadows, then bind it to task.objectList.
  3. Verify the light is a DirectionalLight (a later check in _createShadowGeneratorInstance also requires it).
  4. Move all task configuration above the frameGraph.build()/record() call and assert the inputs are set first.

Example fix

// before
task.light = frameGraph.createLightInputValue(dirLight);
task.record(); // throws: objectList and camera missing

// after
task.light = frameGraph.createLightInputValue(dirLight);
task.objectList = frameGraph.createObjectList([mesh1, mesh2]);
task.camera = frameGraph.createCameraInputValue(camera);
task.record();
Defensive patterns

Strategy: validation

Validate before calling

function csmInputsReady(t: FrameGraphCascadedShadowGeneratorTask): boolean {
    return t.light !== undefined && t.objectList !== undefined && t.camera !== undefined;
}
if (!csmInputsReady(task)) throw new Error("CSM task inputs incomplete");
task.record();

Type guard

function isBound<T>(v: T | undefined): v is T {
    return v !== undefined;
}

Try / catch

try {
    task.record();
} catch (e) {
    if ((e as Error).message.includes("light, objectList and camera are required")) {
        console.error("CSM task missing inputs:", {
            light: task.light,
            objectList: task.objectList,
            camera: task.camera,
        });
    } else throw e;
}

Prevention

When it happens

Trigger: Calling record()/frameGraph.build() before assigning task.light, task.objectList, or task.camera — e.g. omitting task.objectList = frameGraph.createObjectListInput(...) or forgetting the camera assignment.

Common situations: Setting up a CSM task from a template and dropping the objectList assignment; camera created late or swapped; objects list built from an empty/undefined array of meshes; refactoring that renamed a variable leaving an assignment pointing elsewhere.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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