Skip to content

Material migration sets shader field instead of unsetting it #1709

@willeastcott

Description

@willeastcott

Problem

When migrating legacy materials, the migration code sets data.shader to 'blinn' instead of unsetting it. This causes a validation error in the collab-server because the shader field is not defined in the material data schema.

Error

C3 Validation Error at: data.shader

The operation tries to set data.shader from "phong" to "blinn", but the schema doesn't recognize this field.

Root Cause

In src/editor/assets/assets-migrate.ts, the comment says "remove shader" but the code actually sets it:

// remove shader since physical material is now the default
if (asset.has('data.shader')) {
    const shader = asset.get('data.shader');
    asset.set('data.shader', 'blinn');  // BUG: should be unset
    ...
}

Compare this to how fresnelModel is correctly handled just below:

// remove fresnelModel since it is now always set to schlick
if (asset.has('data.fresnelModel')) {
    const fresnelModel = asset.get('data.fresnelModel');
    asset.unset('data.fresnelModel');  // Correct
    ...
}

Fix

Change asset.set('data.shader', 'blinn') to asset.unset('data.shader') to be consistent with how other deprecated fields are handled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions