{"record":{"id":"dec626e7f33b27ff","repo":"stride3d/stride","slug":"last-blurriest-level-must-have-a-coc-of-1-0","errorCode":null,"errorMessage":"Last blurriest level must have a CoC of 1.0!","messagePattern":"Last blurriest level must have a CoC of 1\\.0!","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs","lineNumber":302,"sourceCode":"            }\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            \n            // Special case: level 0 is always our original image\n            cocLevels.Add(new CoCLevelConfig { CoCValue = 0f, DownscaleFactor = 0 });\n            combineShaderCocLevelValues[0] = 0f;\n","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs#L284-L320","documentation":"The last (blurriest) entry in levelCoCValues must be exactly 1.0, since it defines the full circle-of-confusion level that anchors the blur pyramid. SetupTechnique throws ArgumentOutOfRangeException when the final CoC value differs from 1f.","triggerScenarios":"Setting levelCoCValues whose last element is not 1.0 (e.g. {0.5f, 0.8f, 0.9f}) and calling SetupTechnique or rendering.","commonSituations":"Hand-tuned CoC values scaled below 1.0; computing values from aperture formulas that don't normalize the maximum to 1; copying configs and tweaking the last value.","solutions":["Set the last element of levelCoCValues to 1f","Normalize the array so the largest CoC becomes 1.0","Use null/default levels if custom pyramid configuration is not needed"],"exampleFix":"// before\ndof.LevelCoCValues = new[] { 0.25f, 0.5f, 0.75f };\n// after\ndof.LevelCoCValues = new[] { 0.25f, 0.5f, 1.0f };","handlingStrategy":"validation","validationCode":"cocValues[cocValues.Length - 1] = 1f; // enforce blurriest level = 1.0","typeGuard":"bool LastCoCIsOne(float[] coc) => coc == null || coc.Length == 0 || Math.Abs(coc[coc.Length - 1] - 1f) < float.Epsilon;","tryCatchPattern":"try { dof.SetupTechnique(); } catch (ArgumentOutOfRangeException) { dof.LevelCoCValues[^1] = 1f; dof.SetupTechnique(); }","preventionTips":["Always end custom CoC arrays with 1.0","Normalize CoC arrays so the max value maps to 1.0","Note the comparison is exact (!=), so avoid float math on the last element"],"tags":["csharp","argumentoutofrange","depthoffield","rendering"],"backgroundTag":"invalid-config-value","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"}