BabylonJS/Babylon.js · error
Invalid Format '${vertexBuffer.getKind()}' - type=${type}, n
Error message
Invalid Format '${vertexBuffer.getKind()}' - type=${type}, normalized=${normalized}, size=${size} What it means
When building the WebGPU vertex buffer layout, this helper maps (type, normalized, size) tuples of a vertex buffer to a GPUVertexFormat. If the combination has no matching WebGPU vertex format (unsupported component type, size, or normalization flag), it throws with the buffer kind and offending values.
Source
Thrown at packages/dev/core/src/Engines/WebGPU/webgpuCacheRenderPipeline.ts:757
case 4:
return WebGPUConstants.VertexFormat.Uint32x4;
}
break;
case VertexBuffer.FLOAT:
switch (size) {
case 1:
return WebGPUConstants.VertexFormat.Float32;
case 2:
return WebGPUConstants.VertexFormat.Float32x2;
case 3:
return WebGPUConstants.VertexFormat.Float32x3;
case 4:
return WebGPUConstants.VertexFormat.Float32x4;
}
break;
}
throw new Error(`Invalid Format '${vertexBuffer.getKind()}' - type=${type}, normalized=${normalized}, size=${size}`);
}
private _getAphaBlendState(targetIndex: number): Nullable<GPUBlendComponent> {
if (!this._alphaBlendEnabled[targetIndex]) {
return null;
}
return {
srcFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[targetIndex * 4 + 2]),
dstFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[targetIndex * 4 + 3]),
operation: WebGPUCacheRenderPipeline._GetAphaBlendOperation(this._alphaBlendEqParams[targetIndex * 2 + 1]),
};
}
private _getColorBlendState(targetIndex: number): Nullable<GPUBlendComponent> {
if (!this._alphaBlendEnabled) {
return null;
}
View on GitHub (pinned to 0592b347b8)
Solutions
- Convert the attribute data to a supported layout, e.g. Float32Array with size 1-4.
- Adjust the normalized flag: use normalized:false with float data or a supported normalized integer format.
- Inspect the error's type/normalized/size values and match them to a documented WebGPU GPUVertexFormat before creating the buffer.
Example fix
// before new VertexBuffer(engine, new Uint16Array([...]), "normal", false, 64, 0, 3); // u16 x3 unnormalized // after new VertexBuffer(engine, new Float32Array([...]), "normal", false, 64, 0, 3); // float32 x3
Defensive patterns
Strategy: validation
Validate before calling
// Supported combos: float 1-4, uint16/uint8 etc. per WebGPU spec
function hasSupportedVertexLayout(type: number, normalized: boolean, size: number): boolean {
if (type === BABYLON.VertexBuffer.FLOAT) return size >= 1 && size <= 4;
if (type === BABYLON.VertexBuffer.UNSIGNED_SHORT) return size === 2 || size === 4; // u16x3 unnormalized is invalid
if (type === BABYLON.VertexBuffer.UNSIGNED_BYTE) return size === 2 || size === 4;
return false;
}
if (!hasSupportedVertexLayout(type, normalized, size)) convertBufferToFloat32(); Type guard
function hasWebGPUVertexFormat(type: number, normalized: boolean, size: number): boolean {
const V = BABYLON.VertexBuffer;
if (type === V.FLOAT) return size >= 1 && size <= 4;
if (type === V.UNSIGNED_SHORT) return [2, 4].includes(size);
if (type === V.UNSIGNED_BYTE) return [2, 4].includes(size);
return false;
} Try / catch
try {
mesh.setVerticesBuffer(kind, buffer);
} catch (e) {
if (String(e.message).startsWith('Invalid Format')) {
console.warn(`Rebuilding ${kind} as float32x4`, e.message);
mesh.setVerticesBuffer(kind, rebuildAsFloat32(buffer));
} else throw e;
} Prevention
- Prefer Float32Array vertex data with sizes 1-4 for custom attributes.
- Avoid odd sizes (3, 5) on 8/16-bit integer attributes; pad to 4 components.
- Check the WebGPU GPUVertexFormat table before introducing a new vertex kind.
When it happens
Trigger: Attaching a VertexBuffer whose component type/size/normalized combo has no WebGPU equivalent, e.g. a 3-component normalized unsigned-short attribute, or an unusual custom kind with type/size outside the supported set.
Common situations: Custom vertex kinds with hand-built buffers of unusual stride/size; importing meshes with exotic attribute layouts (e.g. byte-based normals at size 3 normalized); passing a wrong 'size' (e.g. 5) or an unnormalized integer type WebGPU cannot consume.
Related errors
- createComputeEffect: This engine does not support compute sh
- Unsupported attribute type: ${type}.
- Can't handle more than 8 attachments for a MRT in cache rend
- WebGPUComputeContext.getBindGroups: bindingsMapping is requi
- WebGPU shader language is only supported with WebGPU engine
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/7398c1e7c9c8847f.
Report an issue: GitHub.