stride3d/stride · error · ArgumentNullException

fogFilterName

Error message

fogFilterName

What it means

Argument-null validation in the Fog(string shaderName) constructor: shaderName is null. The base ImageEffectShader is constructed from this name to load the fog effect; without a shader name the effect cannot locate its shader, so the constructor rejects the null input. (The parameterless Fog() delegates with the default name "FogEffect".)

Solutions

  1. Pass a valid fog shader name string to the constructor
  2. Check the config/lookup that produced the null name and fix it or supply a default (e.g. "FogEffect")
  3. Add a null check/default before constructing Fog

Example fix

// before
var fog = new Fog(settings.FogShaderName); // may be null
// after
var fog = new Fog(settings.FogShaderName ?? "FogEffect");
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(shaderName)) shaderName = "FogEffect"; var fog = new Fog(shaderName);

Type guard

bool IsValidShaderName(string s) => !string.IsNullOrEmpty(s);

Try / catch

try { fog = new Fog(shaderName); } catch (ArgumentNullException) { fog = new Fog("FogEffect"); }

Prevention

When it happens

Trigger: new Fog(null) or passing a shader name variable that is null (e.g. from a missing config field or failed lookup).

Common situations: Loading the shader name from settings/serialization that returned null; renaming a shader so a lookup fails before the constructor; copying examples where a constant was accidentally removed.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/Fog/Fog.cs:35

        private readonly ImageEffectShader fogFilter;
        private Texture depthTexture;
        private float zMin, zMax;

        /// <summary>
        /// Initializes a new instance of the <see cref="Fog"/> class.
        /// </summary>
        public Fog()
            : this("FogEffect") 
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Fog"/> class.
        /// </summary>
        /// <param name="shaderName">Name of the fog shader.</param>
        public Fog(string shaderName) : base(shaderName) 
        {
            if (shaderName == null) throw new ArgumentNullException("fogFilterName");
            fogFilter = new ImageEffectShader(shaderName);
        }

        [DataMember(10)]
        public float Density { get; set; } = 0.1f;

        [DataMember(20)]
        public Color3 Color { get; set; } = new Color3(1.0f);

        [DataMember(30)]
        public float FogStart { get; set; } = 10f;

        [DataMember(40)]
        public bool SkipBackground { get; set; } = false;

        protected override void InitializeCore() 
        {
            base.InitializeCore();

View on GitHub (pinned to 96fad776d2)