{"record":{"id":"76cbdace3d839537","repo":"stride3d/stride","slug":"radius-cannot-be-0-cocmapblur","errorCode":null,"errorMessage":"Radius cannot be < 0","messagePattern":"Radius cannot be < 0","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/CoCMapBlur.cs","lineNumber":51,"sourceCode":"        {\n            Radius = 5f;\n        }\n\n        /// <summary>\n        /// Gets or sets the radius.\n        /// </summary>\n        /// <value>The radius.</value>\n        public float Radius\n        {\n            get\n            {\n                return radius;\n            }\n            set\n            {\n                if (value < 0)\n                {\n                    throw new ArgumentOutOfRangeException(\"Radius cannot be < 0\");\n                }\n\n                weightsDirty = (radius != value);\n                radius = value;\n            }\n        }\n\n        protected override void InitializeCore()\n        {\n            base.InitializeCore();\n\n            cocBlurEffect = ToLoadAndUnload(new ImageEffectShader(\"CoCMapBlurEffect\"));\n        }\n\n        protected override void DrawCore(RenderDrawContext context)\n        {\n            // Updates the weight array if necessary\n            if (weightsDirty || tapCount == 0)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/CoCMapBlur.cs#L33-L69","documentation":"The Radius property of CoCMapBlur's blur weights setter rejects negative values with ArgumentOutOfRangeException. The radius controls the blur kernel size for the circle-of-confusion map and cannot be negative.","triggerScenarios":"Assigning any negative value to the Radius property of CoCMapBlur, e.g. blurEffect.Radius = -1, or computing a radius from a formula that can go below 0.","commonSituations":"Deriving radius from scene scale or resolution where a bad parameter makes it negative; typo in tuning values; data-driven configs with negative entries.","solutions":["Clamp the value before assigning: Radius = Math.Max(0, value)","Fix the calculation or configuration that produced a negative radius","Use 0 radius if no blur is desired instead of a negative one"],"exampleFix":"// before\nblur.Radius = (int)(coc * scale);\n// after\nblur.Radius = Math.Max(0, (int)(coc * scale));","handlingStrategy":"validation","validationCode":"if (radius < 0) throw new ArgumentException(\"Radius must be >= 0\"); blur.Radius = radius;","typeGuard":"bool IsValidRadius(int r) => r >= 0;","tryCatchPattern":"try { blur.Radius = value; } catch (ArgumentOutOfRangeException) { blur.Radius = 0; }","preventionTips":["Clamp kernel radii to >= 0 before assignment","Validate computed radii at low resolutions/scales","Prefer radius 0 semantics for 'no blur' instead of negative values"],"tags":["csharp","argumentoutofrange","blur","rendering"],"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"}