stride3d/stride · error · Exception

[Material] Unknown node type:

Error message

[Material] Unknown node type: 

What it means

ComputeShaderClassBase.GenerateShaderSource maps each generic compute-color parameter type to a string for the ShaderClassSource mixin. When a generic parameter is of a type the switch does not know (neither float, Vector2/3/4, Color, bool, etc.), it throws a plain Exception reporting the unknown node type.

Solutions

  1. Change the generic parameter to a supported type (float, bool, Vector2/3/4, Color4, texture types)
  2. Add a case for your custom parameter type in a derived class overriding the generic mapping
  3. Log the value of generic.GetType() from the message to identify which type is unhandled
  4. Update Stride or the custom mixin so the mixin accepts the parameter type you pass

Example fix

// before: unsupported custom node as generic
generics.Add(myCustomNode);
// after: convert to a supported representation
generics.Add(((ComputeColorParameterFloat)myCustomNode).Value.ToString(CultureInfo.InvariantCulture));
Defensive patterns

Strategy: validation

Validate before calling

if (!(generic is ComputeColorParameterFloat || generic is ComputeColorParameterBool || /* other supported types */ ...))
    throw new ArgumentException($"Unsupported generic type {generic.GetType().Name}");

Type guard

bool IsSupportedGeneric(object g) => g is ComputeColorParameterFloat or ComputeColorParameterBool or ComputeColorParameterVector2 or ComputeColorParameterVector3 or ComputeColorParameterVector4;

Try / catch

try { var src = computeNode.GenerateShaderSource(context, keys); }
catch (Exception ex)
{
    logger.LogError(ex, "Unknown material generic node type");
    src = defaultNode.GenerateShaderSource(context, keys);
}

Prevention

When it happens

Trigger: Passing a custom or unrecognized IComputeNode/parameter type as a generic to a material compute shader class (e.g. a custom ComputeColor parameter type not handled by the type switch), usually from a custom material attribute using unsupported generics.

Common situations: Writing a custom material attribute that supplies generic parameters of a type not among the supported set; a Stride version change adding new parameter types handled by the switch while user code passes older/newer types.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Materials/ComputeColors/ComputeShaderClassBase.cs:148

                    else if (generic is ComputeColorParameterFloat3 paramFloat3)
                    {
                        mixinGenerics.Add(MaterialUtility.GetAsShaderString(paramFloat3.Value));
                    }
                    else if (generic is ComputeColorParameterFloat4 paramFloat4)
                    {
                        mixinGenerics.Add(MaterialUtility.GetAsShaderString(paramFloat4.Value));
                    }
                    else if (generic is ComputeColorStringParameter paramString)
                    {
                        mixinGenerics.Add(paramString.Value);
                    }
                    else if (generic is ComputeColorParameterBool paramBool)
                    {
                        mixinGenerics.Add(paramBool.Value ? "true" : "false");
                    }
                    else
                    {
                        throw new Exception("[Material] Unknown node type: " + generic.GetType());
                    }
                }
                generics = mixinGenerics.ToArray();
            }

            var shaderClassSource = new ShaderClassSource(mixinName, generics);

            if (CompositionNodes.Count == 0)
                return shaderClassSource;

            var mixin = new ShaderMixinSource();
            mixin.Mixins.Add(shaderClassSource);

            foreach (var comp in CompositionNodes)
            {
                var compShader = comp.Value?.GenerateShaderSource(context, baseKeys);
                if (compShader != null)
                    mixin.Compositions.Add(comp.Key, compShader);

View on GitHub (pinned to 96fad776d2)