stride3d/stride · error · ArgumentOutOfRangeException
Radius cannot be < 0
Error message
Radius cannot be < 0
What it means
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.
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
Example fix
// before blur.Radius = (int)(coc * scale); // after blur.Radius = Math.Max(0, (int)(coc * scale));
Defensive patterns
Strategy: validation
Validate before calling
if (radius < 0) throw new ArgumentException("Radius must be >= 0"); blur.Radius = radius; Type guard
bool IsValidRadius(int r) => r >= 0;
Try / catch
try { blur.Radius = value; } catch (ArgumentOutOfRangeException) { blur.Radius = 0; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Deriving radius from scene scale or resolution where a bad parameter makes it negative; typo in tuning values; data-driven configs with negative entries.
Related errors
- DoF configuration needs at least one blur level!
- Last blurriest level must have a CoC of 1.0!
- levelCoCValues and levelDownscaleFactors must be arrays of…
- Radius cannot be < 1
- SigmaRatio cannot be < 0.0f
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/76cbdace3d839537.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/CoCMapBlur.cs:51
{
Radius = 5f;
}
/// <summary>
/// Gets or sets the radius.
/// </summary>
/// <value>The radius.</value>
public float Radius
{
get
{
return radius;
}
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException("Radius cannot be < 0");
}
weightsDirty = (radius != value);
radius = value;
}
}
protected override void InitializeCore()
{
base.InitializeCore();
cocBlurEffect = ToLoadAndUnload(new ImageEffectShader("CoCMapBlurEffect"));
}
protected override void DrawCore(RenderDrawContext context)
{
// Updates the weight array if necessary
if (weightsDirty || tapCount == 0)View on GitHub (pinned to 96fad776d2)