{"record":{"id":"f48669f5e86056e9","repo":"stride3d/stride","slug":"expecting-less-than-0-textures-in-input","errorCode":null,"errorMessage":"Expecting less than {0} textures in input","messagePattern":"Expecting less than (.+?) textures in input","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/ImageEffectShader.cs","lineNumber":136,"sourceCode":"        /// <remarks>By default, all the input textures will be remapped to <see cref=\"TexturingKeys.Texture0\" />...etc.</remarks>\n        protected virtual void UpdateParameters()\n        {\n            // By default, we are copying all input textures to TexturingKeys.Texture#\n            var count = InputCount;\n            for (int i = 0; i < count; i++)\n            {\n                var texture = GetInput(i);\n                if (i < TexturingKeys.DefaultTextures.Count)\n                {\n                    var texturingKeys = texture != null && texture.ViewDimension == TextureDimension.TextureCube ? TexturingKeys.TextureCubes : TexturingKeys.DefaultTextures;\n                    var texelSize = texture != null ? new Vector2(1.0f / texture.ViewWidth, 1.0f / texture.ViewHeight) : default;\n                    // TODO GRAPHICS REFACTOR Do not use slow version\n                    Parameters.Set(texturingKeys[i], texture);\n                    Parameters.Set(TexturingKeys.TexturesTexelSize[i], texelSize);\n                }\n                else\n                {\n                    throw new InvalidOperationException(\"Expecting less than {0} textures in input\".ToFormat(TexturingKeys.DefaultTextures.Count));\n                }\n            }\n        }\n\n        protected override unsafe void DrawCore(RenderDrawContext context)\n        {\n            // Clear render targets if there is a dependency conflict (D3D11 warning)\n            if (delaySetRenderTargets)\n                context.CommandList.ResetTargets();\n\n            if (EffectInstance.UpdateEffect(GraphicsDevice) || pipelineStateDirty || previousBytecode != EffectInstance.Effect.Bytecode)\n            {\n                // The EffectInstance might have been updated from outside\n                previousBytecode = EffectInstance.Effect.Bytecode;\n\n                pipelineState.State.RootSignature = EffectInstance.RootSignature;\n                pipelineState.State.EffectBytecode = EffectInstance.Effect.Bytecode;\n                pipelineState.State.BlendState = blendState;","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/ImageEffectShader.cs#L118-L154","documentation":"UpdateParameters binds the effect's input textures to shader parameter slots and throws InvalidOperationException when there are more input textures than TexturingKeys.DefaultTextures.Count supports. The message is a literal template string that was never formatted via string.Format (ToFormat is applied), reporting the maximum texture count.","triggerScenarios":"Calling effect.SetInput(...) with more textures than TexturingKeys.DefaultTextures.Count (bounded loop capacity) and then drawing — PreDrawCore -> UpdateParameters hits the else branch for index i beyond the key array length.","commonSituations":"Feeding a large texture array (e.g. many shadow maps / layered inputs) into an image effect sized for fewer inputs; upgrading code where the default textures key set shrank; reusing a generic effect class with too many inputs.","solutions":["Reduce the number of SetInput calls to at most TexturingKeys.DefaultTextures.Count","Extend the TexturingKeys.DefaultTextures array to support more slots","Pack multiple textures into an atlas/texture array instead of separate slots"],"exampleFix":"// before\nfor (int i = 0; i < 8; i++) effect.SetInput(i, inputs[i]); // only 4 slots\n// after\nfor (int i = 0; i < Math.Min(inputs.Count, TexturingKeys.DefaultTextures.Count); i++)\n    effect.SetInput(i, inputs[i]);","handlingStrategy":"validation","validationCode":"if (inputCount > TexturingKeys.DefaultTextures.Count) throw new InvalidOperationException($\"Max {TexturingKeys.DefaultTextures.Count} inputs supported\");","typeGuard":null,"tryCatchPattern":"try { effect.Draw(context); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Expecting less than\")) { /* reduce inputs or extend key set */ }","preventionTips":["Limit image effect inputs to TexturingKeys.DefaultTextures.Count","Use texture atlases/arrays for many-source passes","Add a startup assertion comparing SetInput count with the key set size"],"tags":["invalid-state","capacity-limit","rendering"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}