{"record":{"id":"d7332bb3173b7991","repo":"BabylonJS/Babylon.js","slug":"invalid-channel-input-configuration","errorCode":null,"errorMessage":"Invalid channel input configuration","messagePattern":"Invalid channel input configuration","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Materials/Textures/textureMerger.ts","lineNumber":128,"sourceCode":"                if (channel.sourceChannel < 0 || channel.sourceChannel > 3) {\n                    throw new Error(\"Source channel must be between 0 and 3 (R, G, B, A)\");\n                }\n\n                // Find or add texture to inputs\n                let textureIndex = textureInputs.indexOf(channel.texture);\n                if (textureIndex === -1) {\n                    textureIndex = textureInputs.length;\n                    textureInputs.push(channel.texture);\n                }\n                textureInputMap[channelIndex] = textureIndex;\n            } else if (IsConstantInput(channel)) {\n                // Validate constant value\n                if (channel.value < 0 || channel.value > 1) {\n                    throw new Error(\"Constant value must be between 0.0 and 1.0\");\n                }\n                textureInputMap[channelIndex] = -1;\n            } else {\n                throw new Error(\"Invalid channel input configuration\");\n            }\n        } else {\n            textureInputMap[channelIndex] = -1;\n        }\n    }\n\n    // Determine output size\n    let outputSize = config.outputSize;\n    if (!outputSize && textureInputs.length > 0) {\n        // Use the largest texture size\n        let maxSize = 0;\n        for (const texture of textureInputs) {\n            const size = texture.getSize();\n            const currentSize = Math.max(size.width, size.height);\n            if (currentSize > maxSize) {\n                maxSize = currentSize;\n                outputSize = size.width === size.height ? maxSize : size;\n            }","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Materials/Textures/textureMerger.ts#L110-L146","documentation":"MergeTexturesAsync decides per channel whether the input is a texture input, a constant input, or absent. This error is thrown when the channel object is present but matches neither recognized input shape — i.e. a malformed configuration object.","triggerScenarios":"Passing a channel object to MergeTexturesAsync that is neither a texture input (has .texture) nor a constant input (has .value) — e.g. { texture: undefined, value: undefined }, a wrong property name, or an object created with a broken factory.","commonSituations":"Typos like { textureId } or { tex } instead of { texture }, passing a raw Texture instead of a channel descriptor, deserialized config that lost its shape, API version change in the merger input types.","solutions":["Ensure each non-null channel is exactly { texture: BaseTexture, sourceChannel: 0-3 } or { value: 0-1 }.","Log the channel object before calling to confirm the property names and that the intended field is not undefined.","Use the documented helper (e.g. CreateMergedAnisotropyTexture) instead of building raw channel configs by hand."],"exampleFix":"// before\n{ tex: roughnessTexture, sourceChannel: 2 }\n// after\n{ texture: roughnessTexture, sourceChannel: 2 }","handlingStrategy":"type-guard","validationCode":"type TextureInput = { texture: BaseTexture; sourceChannel: number };\ntype ConstantInput = { value: number };\nfunction isValidChannel(c: unknown): c is TextureInput | ConstantInput {\n  if (c == null || typeof c !== \"object\") return false;\n  const o = c as any;\n  return (\"texture\" in o && o.texture != null) || typeof o.value === \"number\";\n}","typeGuard":"function isTextureInput(c: unknown): c is { texture: BaseTexture; sourceChannel: number } {\n  return !!c && typeof c === \"object\" && \"texture\" in c && (c as any).texture != null;\n}","tryCatchPattern":"try {\n  const tex = await MergeTexturesAsync(channels, w, h, scene);\n} catch (e) {\n  if (String(e.message).includes(\"Invalid channel input configuration\")) {\n    console.error(\"Each channel must be {texture, sourceChannel} or {value}:\", channels);\n  }\n}","preventionTips":["Use discriminated union types for channel inputs and exhaustiveness checks.","Validate deserialized channel configs before calling the merger.","Prefer documented helpers like CreateMergedAnisotropyTexture over raw configs."],"tags":["texture-merger","config-validation","type-mismatch"],"backgroundTag":"invalid-channel-input-config","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}