stride3d/stride · error · ArgumentOutOfRangeException

Unknown bokeh technique:

Error message

Unknown bokeh technique: 

What it means

BokehTechnique.CreateBokeh maps a BokehTechnique enum value to a concrete bokeh kernel instance. The default case throws ArgumentOutOfRangeException when the enum value is not one of the handled techniques. This guards against out-of-range enum casts or newly added enum members not yet implemented here.

Solutions

  1. Set the BokehTechnique property to a supported value (McIntosh or HexagonalTripleRhombi)
  2. Check for int-to-enum casts and validate with Enum.IsDefined before passing
  3. If a new enum member was added, update the switch in BokehTechnique.CreateBokeh to handle it

Example fix

// before
bokeh.BokehTechnique = (BokehTechnique)saveData.bokehId;
// after
var technique = (BokehTechnique)saveData.bokehId;
if (!Enum.IsDefined(typeof(BokehTechnique), technique)) technique = BokehTechnique.McIntosh;
bokeh.BokehTechnique = technique;
Defensive patterns

Strategy: validation

Validate before calling

if (!Enum.IsDefined(typeof(BokehTechnique), technique)) throw new InvalidOperationException($"Unsupported bokeh technique: {technique}");

Type guard

bool IsValidBokehTechnique(BokehTechnique t) => Enum.IsDefined(typeof(BokehTechnique), t);

Try / catch

try { bokehInstance = BokehTechniqueHelper.CreateBokeh(technique); } catch (ArgumentOutOfRangeException) { bokehInstance = new McIntoshBokeh(); }

Prevention

When it happens

Trigger: Calling CreateBokeh with a BokehTechnique value not covered by the switch, e.g. an enum value cast from an out-of-range int or a newer enum member than this switch handles.

Common situations: Deserializing a DoF render stage configuration from old/foreign data containing an unrecognized integer; adding a new BokehTechnique enum member without updating CreateBokeh; game save files carrying stale enum values across engine versions.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/61aa40e027a87121. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/BokehTechnique/BokehTechnique.cs:60

        /// Instantiates a new <see cref="BokehBlur"/> from a technique name.
        /// </summary>
        /// <param name="name"></param>
        /// <returns>A Bokeh blur corresponding to the tehcnique specified.</returns>
        public static BokehBlur ToBlurInstance(this BokehTechnique name)
        {
            switch (name)
            {
                case BokehTechnique.CircularGaussian:
                    return new GaussianBokeh();

                case BokehTechnique.HexagonalMcIntosh:
                    return new McIntoshBokeh();

                case BokehTechnique.HexagonalTripleRhombi:
                    return new TripleRhombiBokeh();

                default:
                    throw new ArgumentOutOfRangeException("Unknown bokeh technique: " + name);
            }
        }
    }       
}

View on GitHub (pinned to 96fad776d2)