{"record":{"id":"56f222d6050cdf3d","repo":"stride3d/stride","slug":"dof-configuration-needs-at-least-one-blur-level","errorCode":null,"errorMessage":"DoF configuration needs at least one blur level!","messagePattern":"DoF configuration needs at least one blur level!","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs","lineNumber":298,"sourceCode":"            // Sanity checks\n            if (levelCoCValues == null && levelDownscaleFactors != null)\n            {\n                throw new ArgumentOutOfRangeException(\"You cannot provide downscale factors without CoC values first.\");\n            }\n\n            if (levelCoCValues != null && levelDownscaleFactors != null)\n            {\n                if (levelCoCValues.Length != levelDownscaleFactors.Length)\n                {\n                    throw new ArgumentOutOfRangeException(\"levelCoCValues and levelDownscaleFactors must be arrays of the same size!\");\n                }\n            }\n\n            if (levelCoCValues != null && levelCoCValues.Length == 0)\n            {\n                if (levelCoCValues.Length == 0)\n                {\n                    throw new ArgumentOutOfRangeException(\"DoF configuration needs at least one blur level!\");\n                }\n                if (levelCoCValues[levelCoCValues.Length - 1] != 1f)\n                {\n                    throw new ArgumentOutOfRangeException(\"Last blurriest level must have a CoC of 1.0!\");\n                }\n            }\n\n            // Default values: 1 original image and 1 blur level\n            int levelCount = 2;\n            if (levelCoCValues != null)\n            {\n                levelCount = levelCoCValues.Length + 1;\n            }\n\n            CleanupEffects();\n            cocLevels.Clear();\n            combineShaderCocLevelValues = new float[levelCount];\n            ","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs#L280-L316","documentation":"DepthOfField.SetupTechnique requires at least one entry in levelCoCValues; an empty array provides no blur level configuration and throws ArgumentOutOfRangeException. The multi-level DoF pipeline cannot be built without any level definitions.","triggerScenarios":"Assigning an empty array (new float[0]) to levelCoCValues, then calling SetupTechnique or rendering.","commonSituations":"Building level arrays programmatically where a filter produced zero elements; clearing the array intending to reset to defaults but the non-null empty array still triggers validation.","solutions":["Assign a non-empty CoC array (last value must be 1.0)","Set levelCoCValues to null to fall back to the default 2-level configuration","Fix the generating code so it produces at least one level"],"exampleFix":"// before\ndof.LevelCoCValues = collectedLevels.ToArray(); // empty\n// after\nvar levels = collectedLevels.ToArray();\ndof.LevelCoCValues = levels.Length > 0 ? levels : null; // null = defaults","handlingStrategy":"validation","validationCode":"if (cocValues != null && cocValues.Length == 0) cocValues = null; // null = use defaults","typeGuard":"bool HasAtLeastOneLevel(float[] coc) => coc == null || coc.Length > 0;","tryCatchPattern":"try { dof.SetupTechnique(); } catch (ArgumentOutOfRangeException) { dof.LevelCoCValues = null; dof.SetupTechnique(); }","preventionTips":["Treat empty custom level arrays as 'use defaults' (assign null instead)","Check array length after any filtering/generation step","Write a unit test for the empty-array case"],"tags":["csharp","argumentoutofrange","depthoffield","rendering"],"backgroundTag":"empty-required-field","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"}