{"record":{"id":"504d42619f366eab","repo":"stride3d/stride","slug":"you-cannot-provide-downscale-factors-without-coc-values","errorCode":null,"errorMessage":"You cannot provide downscale factors without CoC values first.","messagePattern":"You cannot provide downscale factors without CoC values first\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs","lineNumber":283,"sourceCode":"        /// </summary>\n        /// <param name=\"colorBuffer\">A color buffer to process.</param>\n        /// <param name=\"depthBuffer\">The depth buffer corresponding to the color buffer provided.</param>\n        public void SetColorDepthInput(Texture colorBuffer, Texture depthBuffer)\n        {\n            SetInput(0, colorBuffer);\n            SetInput(1, depthBuffer);\n        }\n\n        /// <summary>\n        /// Caches the current configuration and re-generates the filter effect of each LOD level to avoid \n        /// generating garbage a each frame.\n        /// </summary>\n        public void SetupTechnique()\n        {\n            // 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                {","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs#L265-L301","documentation":"DepthOfField.SetupTechnique validates that downscale factors are only provided alongside their matching CoC (circle-of-confusion) values. If levelDownscaleFactors is set but levelCoCValues is null, it throws ArgumentOutOfRangeException. Each blur level is defined by a CoC value plus a downscale factor, so factors alone are meaningless.","triggerScenarios":"Calling the levelDownscaleFactors property setter without first setting levelCoCValues, then invoking SetupTechnique (directly or via DrawCore).","commonSituations":"Partially populating the DoF level arrays; copying a code sample that sets only downscale factors; resetting CoC values to null while leaving factors assigned.","solutions":["Assign levelCoCValues before assigning levelDownscaleFactors","Set both arrays to the same non-null arrays or clear both together","Remove the downscale factors assignment if custom levels are not intended"],"exampleFix":"// before\ndof.LevelDownscaleFactors = new[] { 1, 2, 4 };\ndof.SetupTechnique();\n// after\ndof.LevelCoCValues = new[] { 0.5f, 0.75f, 1.0f };\ndof.LevelDownscaleFactors = new[] { 1, 2, 4 };\ndof.SetupTechnique();","handlingStrategy":"validation","validationCode":"if (dof.LevelDownscaleFactors != null && dof.LevelCoCValues == null) dof.LevelDownscaleFactors = null;","typeGuard":"bool CanSetupDoF(float[] coc, int[] dsf) => dsf == null || coc != null;","tryCatchPattern":"try { dof.SetupTechnique(); } catch (ArgumentOutOfRangeException) { dof.LevelCoCValues = null; dof.LevelDownscaleFactors = null; dof.SetupTechnique(); }","preventionTips":["Always set levelCoCValues before levelDownscaleFactors","Clear both arrays together when resetting","Build both arrays from one shared level-definition list"],"tags":["csharp","argumentoutofrange","depthoffield","rendering"],"backgroundTag":"missing-required-argument","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"}