stride3d/stride · error · ArgumentOutOfRangeException
You cannot provide downscale factors without CoC values…
Error message
You cannot provide downscale factors without CoC values first.
What it means
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.
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
Example fix
// before
dof.LevelDownscaleFactors = new[] { 1, 2, 4 };
dof.SetupTechnique();
// after
dof.LevelCoCValues = new[] { 0.5f, 0.75f, 1.0f };
dof.LevelDownscaleFactors = new[] { 1, 2, 4 };
dof.SetupTechnique(); Defensive patterns
Strategy: validation
Validate before calling
if (dof.LevelDownscaleFactors != null && dof.LevelCoCValues == null) dof.LevelDownscaleFactors = null;
Type guard
bool CanSetupDoF(float[] coc, int[] dsf) => dsf == null || coc != null;
Try / catch
try { dof.SetupTechnique(); } catch (ArgumentOutOfRangeException) { dof.LevelCoCValues = null; dof.LevelDownscaleFactors = null; dof.SetupTechnique(); } Prevention
- Always set levelCoCValues before levelDownscaleFactors
- Clear both arrays together when resetting
- Build both arrays from one shared level-definition list
When it happens
Trigger: Calling the levelDownscaleFactors property setter without first setting levelCoCValues, then invoking SetupTechnique (directly or via DrawCore).
Common situations: Partially populating the DoF level arrays; copying a code sample that sets only downscale factors; resetting CoC values to null while leaving factors assigned.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
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 < 0
- Radius cannot be < 1
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/504d42619f366eab.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs:283
/// </summary>
/// <param name="colorBuffer">A color buffer to process.</param>
/// <param name="depthBuffer">The depth buffer corresponding to the color buffer provided.</param>
public void SetColorDepthInput(Texture colorBuffer, Texture depthBuffer)
{
SetInput(0, colorBuffer);
SetInput(1, depthBuffer);
}
/// <summary>
/// Caches the current configuration and re-generates the filter effect of each LOD level to avoid
/// generating garbage a each frame.
/// </summary>
public void SetupTechnique()
{
// Sanity checks
if (levelCoCValues == null && levelDownscaleFactors != null)
{
throw new ArgumentOutOfRangeException("You cannot provide downscale factors without CoC values first.");
}
if (levelCoCValues != null && levelDownscaleFactors != null)
{
if (levelCoCValues.Length != levelDownscaleFactors.Length)
{
throw new ArgumentOutOfRangeException("levelCoCValues and levelDownscaleFactors must be arrays of the same size!");
}
}
if (levelCoCValues != null && levelCoCValues.Length == 0)
{
if (levelCoCValues.Length == 0)
{
throw new ArgumentOutOfRangeException("DoF configuration needs at least one blur level!");
}
if (levelCoCValues[levelCoCValues.Length - 1] != 1f)
{View on GitHub (pinned to 96fad776d2)