BabylonJS/Babylon.js · error · Error

`Unsupported uniform type: '${uniformTypeString}'`

Error message

`Unsupported uniform type: '${uniformTypeString}'`

What it means

ParseFragmentShader converts the uniform's GLSL type to a ConnectionPointType via a switch over a fixed set of supported types (float, vec2, etc.). Any type outside that list hits the default branch and throws, listing the offending type.

Source

Thrown at packages/dev/smartFilters/src/utils/buildTools/shaderConverter.ts:173

                type = ConnectionPointType.Float;
                break;
            case "sampler2D":
                type = ConnectionPointType.Texture;
                break;
            case "vec3":
                type = ConnectionPointType.Color3;
                break;
            case "vec4":
                type = ConnectionPointType.Color4;
                break;
            case "bool":
                type = ConnectionPointType.Boolean;
                break;
            case "vec2":
                type = ConnectionPointType.Vector2;
                break;
            default:
                throw new Error(`Unsupported uniform type: '${uniformTypeString}'`);
        }

        uniforms.push({
            name: uniformName,
            type,
            properties: annotationJSON ? JSON.parse(annotationJSON.replace("//", "").trim()) : undefined,
        });

        if (annotationJSON) {
            // Strip out any annotation so it isn't mistaken for function bodies
            fragmentShader = fragmentShader.replace(annotationJSON, "");
        }
    }

    // Read the property consts (consts to be exposed as properties)
    const fragmentConstProperties: ConstPropertyMetadata[] = [];
    const constRegExp = new RegExp(/(\/\/\s*\{.*\}\s*(?:\r\n|\r|\n)+)?(const .*)/gm);
    const constGroups = fragmentShader.matchAll(constRegExp);

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Change the uniform to a supported type (float, Boolean, vec2, or whatever the version's switch supports).
  2. Split unsupported types (mat4, arrays) into multiple supported uniforms.
  3. Check the source switch statement in shaderConverter.ts for the exact list of supported types in your version.

Example fix

// before
uniform mat4 transform;
// after
uniform vec4 transformRow0;
uniform vec4 transformRow1;
Defensive patterns

Strategy: validation

Validate before calling

const supported = new Set(['float', 'vec2']); // check shaderConverter.ts switch for your version
src.split('\n').forEach((l, i) => { const m = l.trim().match(/^uniform\s+(\w+)\s+(\w+)\s*;?$/); if (m && !supported.has(m[1])) console.error(`Unsupported uniform type '${m[1]}' at line ${i+1}`); });

Type guard

const hasSupportedUniformType = (line: string): boolean => { const m = line.trim().match(/^uniform\s+(\w+)\s+\w+\s*;?$/); return !!m && ['float','vec2'].includes(m[1]); };

Try / catch

try { await ConvertShader(path, ...); } catch (e) { const m = e.message.match(/Unsupported uniform type: '(\w+)'/); if (m) { replaceUnsupportedType(m[1]); } else { throw e; } }

Prevention

When it happens

Trigger: Declaring a uniform with an unsupported GLSL type — e.g. int, mat4, vec4 (if unsupported in this version), sampler2D, or any non-scalar/vector type in the supported switch.

Common situations: Using standard GLSL types the smart filter binding layer does not model; porting general-purpose shaders into blocks; version differences where a type was added later.

Related errors


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