{"record":{"id":"34826542a781d437","repo":"stride3d/stride","slug":"asked-for-i-but-no-more-than-10-default-textures-are","errorCode":null,"errorMessage":"Asked for \" + i + \" but no more than 10 default textures are currently supported","messagePattern":"Asked for \" \\+ i \\+ \" but no more than 10 default textures are currently supported","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Materials/MaterialUtility.cs","lineNumber":136,"sourceCode":"                    return TexturingKeys.Sampler1;\n                case 2:\n                    return TexturingKeys.Sampler2;\n                case 3:\n                    return TexturingKeys.Sampler3;\n                case 4:\n                    return TexturingKeys.Sampler4;\n                case 5:\n                    return TexturingKeys.Sampler5;\n                case 6:\n                    return TexturingKeys.Sampler6;\n                case 7:\n                    return TexturingKeys.Sampler7;\n                case 8:\n                    return TexturingKeys.Sampler8;\n                case 9:\n                    return TexturingKeys.Sampler9;\n                default:\n                    throw new ArgumentOutOfRangeException(\"Asked for \" + i + \" but no more than 10 default textures are currently supported\");\n            }\n        }\n\n        /// <summary>\n        /// Clamps <see cref=\"ComputeColors.ComputeFloat\"/> value within a specified range [min; max].\n        /// </summary>\n        /// <param name=\"key\">Input scalar.</param>\n        /// <param name=\"min\">The minimum value.</param>\n        /// <param name=\"max\">The maximum value.</param>\n        public static void ClampFloat([NotNull] this IComputeScalar key, float min, float max)\n        {\n            var asFloat = key as ComputeColors.ComputeFloat;\n            if (asFloat != null)\n                asFloat.Value = MathUtil.Clamp(asFloat.Value, min, max);\n        }\n\n        /// <summary>\n        /// Clamps <see cref=\"ComputeColors.ComputeFloat4\"/> value within a specified range [min; max].","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Materials/MaterialUtility.cs#L118-L154","documentation":"MaterialUtility.GetDefaultSamplerKey maps a sampler index to the corresponding TexturingKeys.SamplerN name; the engine supports indices 0 through 9. A negative or >= 10 index hits the default case and throws ArgumentOutOfRangeException.","triggerScenarios":"Calling MaterialUtility.GetDefaultSamplerKey with an index < 0 or > 9, typically from a custom material pass or shader generator that loops over more textures/samplers than the 10 default slots.","commonSituations":"Custom material generators iterating texture arrays larger than 10; off-by-one or negative index from a computed sampler slot.","solutions":["Clamp or reject sampler indices to 0..9 before calling GetDefaultSamplerKey","Rework custom materials needing more samplers to use explicit sampler names instead of the defaults","Keep the texture count of the material within the 10-default-sampler limit"],"exampleFix":"// before\nvar key = MaterialUtility.GetDefaultSamplerKey(textureIndex);\n// after\nif (textureIndex < 0 || textureIndex > 9)\n    throw new ArgumentOutOfRangeException(nameof(textureIndex), \"Only samplers 0..9 are supported\");\nvar key = MaterialUtility.GetDefaultSamplerKey(textureIndex);","handlingStrategy":"validation","validationCode":"if (index < 0 || index > 9) throw new ArgumentOutOfRangeException(nameof(index));\nvar samplerKey = MaterialUtility.GetDefaultSamplerKey(index);","typeGuard":null,"tryCatchPattern":"try { key = MaterialUtility.GetDefaultSamplerKey(i); }\ncatch (ArgumentOutOfRangeException) { key = TexturingKeys.Sampler0; /* or fail fast */ }","preventionTips":["Design custom materials to use at most 10 default samplers","Clamp indices computed from texture counts","Use explicitly named samplers when exceeding the defaults"],"tags":["rendering","materials","argument-out-of-range"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}