{"record":{"id":"e99b2268ed33fc8b","repo":"BabylonJS/Babylon.js","slug":"unsupported-alpha-mode-mode","errorCode":null,"errorMessage":"Unsupported alpha mode: ${mode}.","messagePattern":"Unsupported alpha mode: (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/Native/nativeHelpers.ts","lineNumber":351,"sourceCode":"            return _native.Engine.ALPHA_MAXIMIZED;\r\n        case Constants.ALPHA_ONEONE:\r\n            return _native.Engine.ALPHA_ONEONE;\r\n        case Constants.ALPHA_ONEONE_ONEONE:\r\n            return _native.Engine.ALPHA_ONEONE_ONEONE ?? _getFallbackAlphaMode(mode, \"ALPHA_ONEONE_ONEONE\");\r\n        case Constants.ALPHA_LAYER_ACCUMULATE:\r\n            return _native.Engine.ALPHA_LAYER_ACCUMULATE ?? _getFallbackAlphaMode(mode, \"ALPHA_LAYER_ACCUMULATE\");\r\n        case Constants.ALPHA_PREMULTIPLIED:\r\n            return _native.Engine.ALPHA_PREMULTIPLIED;\r\n        case Constants.ALPHA_PREMULTIPLIED_PORTERDUFF:\r\n            return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;\r\n        case Constants.ALPHA_INTERPOLATE:\r\n            return _native.Engine.ALPHA_INTERPOLATE;\r\n        case Constants.ALPHA_SCREENMODE:\r\n            return _native.Engine.ALPHA_SCREENMODE;\r\n        case Constants.ALPHA_REPLACE_COLOR:\r\n            return _native.Engine.ALPHA_REPLACE_COLOR ?? _getFallbackAlphaMode(mode, \"ALPHA_REPLACE_COLOR\", _native.Engine.ALPHA_COMBINE, \"ALPHA_COMBINE\");\r\n        default:\r\n            throw new Error(`Unsupported alpha mode: ${mode}.`);\r\n    }\r\n}\r\n\r\nexport function getNativeAttribType(type: number): number {\r\n    switch (type) {\r\n        case VertexBuffer.BYTE:\r\n            return _native.Engine.ATTRIB_TYPE_INT8;\r\n        case VertexBuffer.UNSIGNED_BYTE:\r\n            return _native.Engine.ATTRIB_TYPE_UINT8;\r\n        case VertexBuffer.SHORT:\r\n            return _native.Engine.ATTRIB_TYPE_INT16;\r\n        case VertexBuffer.UNSIGNED_SHORT:\r\n            return _native.Engine.ATTRIB_TYPE_UINT16;\r\n        case VertexBuffer.FLOAT:\r\n            return _native.Engine.ATTRIB_TYPE_FLOAT;\r\n        // HALF_FLOAT (as well as INT and UNSIGNED_INT) has no equivalent in the native bindings, which only\r\n        // expose ATTRIB_TYPE_INT8/UINT8/INT16/UINT16/FLOAT. Those vertex attribute types are therefore\r\n        // WebGL/WebGPU only and intentionally fall through to the throw below on the Babylon Native engine.\r","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/Native/nativeHelpers.ts#L333-L369","documentation":"getNativeAlphaMode converts a Babylon Constants.ALPHA_* blending mode to the native engine's ALPHA_* enum, with fallbacks for newer modes on older native runtimes. If the mode is not a recognized alpha mode at all, it throws. The library throws because the native engine cannot represent an unknown blend mode.","triggerScenarios":"Setting material.alphaMode (or calling setAlphaMode) with a value that is not a Constants.ALPHA_* constant, e.g. an arbitrary number, undefined, or NaN.","commonSituations":"Custom blend modes invented by app code; serialization restoring a corrupted alphaMode; using an alpha mode from a much newer Babylon version against an older native runtime that also lacks the fallback.","solutions":["Set material.alphaMode to a valid Constants.ALPHA_* value (e.g. Constants.ALPHA_COMBINE, Constants.ALPHA_SCREENMODE).","Validate the stored/loaded alphaMode against Constants before assigning.","Upgrade both the Babylon.js package and the native engine binaries so newer alpha modes and their fallbacks exist."],"exampleFix":"// before\nmaterial.alphaMode = 99;\n// after\nmaterial.alphaMode = Constants.ALPHA_COMBINE;","handlingStrategy":"validation","validationCode":"const ALPHA_MODES = new Set([BABYLON.Constants.ALPHA_DISABLE, BABYLON.Constants.ALPHA_ADD, BABYLON.Constants.ALPHA_COMBINE, BABYLON.Constants.ALPHA_SUBTRACT, BABYLON.Constants.ALPHA_MULTIPLY, BABYLON.Constants.ALPHA_MAXIMIZED, BABYLON.Constants.ALPHA_ONEONE, BABYLON.Constants.ALPHA_SCREENMODE]);\nif (!ALPHA_MODES.has(mode)) throw new RangeError(`alphaMode must be a Constants.ALPHA_* value, got ${mode}`);\nmaterial.alphaMode = mode;","typeGuard":"function isAlphaMode(v: unknown): v is number {\n  const C = BABYLON.Constants;\n  return typeof v === 'number' && [C.ALPHA_DISABLE, C.ALPHA_ADD, C.ALPHA_COMBINE, C.ALPHA_SUBTRACT, C.ALPHA_MULTIPLY, C.ALPHA_MAXIMIZED, C.ALPHA_ONEONE, C.ALPHA_SCREENMODE].includes(v);\n}","tryCatchPattern":"try {\n  material.alphaMode = mode;\n} catch (e) {\n  if (String(e.message).startsWith('Unsupported alpha mode')) {\n    console.warn('Bad alphaMode, using ALPHA_COMBINE', mode);\n    material.alphaMode = BABYLON.Constants.ALPHA_COMBINE;\n  } else throw e;\n}","preventionTips":["Never assign raw numbers to material.alphaMode; always use Constants.ALPHA_*.","Sanitize alphaMode values restored from serialized scenes before applying them.","Keep Babylon.js and the native runtime versions in sync when using newer alpha modes."],"tags":["babylonjs","alpha-blending","native-engine","invalid-enum"],"backgroundTag":"unsupported-enum-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}