BabylonJS/Babylon.js · error · Error

Unsupported OpenPBR property type.

Error message

Unsupported OpenPBR property type.

What it means

OpenPBR material property registration computes component counts via _GetComponentCount (called by destinationSize/numComponents), which only recognizes number, Vector2, Vector3/Color3, and Vector4/Color4 values. A property with any other runtime type reaches the fallback and throws.

Source

Thrown at packages/dev/core/src/Materials/PBR/openpbrMaterial.pure.ts:92

import { RegisterClass } from "../../Misc/typeStore";

const onCreatedEffectParameters = { effect: null as unknown as Effect, subMesh: null as unknown as Nullable<SubMesh> };

function _GetComponentCount(value: PropertyType): number {
    if (typeof value === "number") {
        return 1;
    }
    if (value instanceof Vector2) {
        return 2;
    }
    if (value instanceof Vector3 || value instanceof Color3) {
        return 3;
    }
    if (value instanceof Vector4 || value instanceof Color4) {
        return 4;
    }

    throw new Error("Unsupported OpenPBR property type.");
}

class Uniform {
    public name: string;
    public numComponents: number;
    public linkedProperties: { [name: string]: Property<PropertyType> } = {};
    /**
     * Cached key of the first entry of `linkedProperties`, set when the first
     * property is linked. Used by the per-frame bind loop to avoid an
     * `Object.keys(linkedProperties)[0]` allocation when reading scalar
     * uniforms.
     */
    public firstLinkedKey: string = "";
    /**
     * Optional define name. If set, the per-frame bind loop will skip pushing
     * this uniform to the UBO unless `defines[requiredDefine]` is true. The
     * UBO slot still exists in the layout; only the per-frame update is
     * skipped, which is safe because the shader only reads these uniforms

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Convert before assignment: Number(v) for scalars, or construct Vector2/Vector3/Vector4/Color3/Color4
  2. Log the property name and typeof value to find which property has the wrong type
  3. Map booleans to 0/1 numbers and restructure matrices into supported vector types

Example fix

// before
mat.setProperty('metalness', cfg.metalness); // '0.8' (string)
// after
const m = Number(cfg.metalness);
mat.setProperty('metalness', Number.isFinite(m) ? m : 0);
Defensive patterns

Strategy: type-guard

Validate before calling

function isSupportedOpenPBRValue(v: unknown): boolean {
  return typeof v === 'number' || v instanceof Vector2 || v instanceof Vector3 ||
    v instanceof Vector4 || v instanceof Color3 || v instanceof Color4;
}

Type guard

const isOpenPBRValue = (v: unknown): v is number | Vector2 | Vector3 | Vector4 | Color3 | Color4 =>
  typeof v === 'number' || v instanceof Vector2 || v instanceof Vector3 || v instanceof Vector4 || v instanceof Color3 || v instanceof Color4;

Try / catch

try {
  mat.setProperty(name, value);
} catch (e) {
  if (e instanceof Error && e.message.includes('Unsupported OpenPBR property type')) {
    console.error(`Property '${name}' has unsupported type:`, typeof value, value);
  } else throw e;
}

Prevention

When it happens

Trigger: openpbrMaterial property assignment where the value is a string, boolean, Matrix, or null instead of a numeric/vector type.

Common situations: Feeding config/JSON material parameters straight into OpenPBR properties without type mapping; accidentally passing '0.5' as a string; passing booleans or matrices where vectors are required.

Related errors


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