{"record":{"id":"e0b68d6364cd5282","repo":"stride3d/stride","slug":"type-type-name-is-not-supported-you-must-specify-an-explicit","errorCode":null,"errorMessage":"Type [{type.Name}] is not supported. You must specify an explicit PixelFormat","messagePattern":"Type \\[(.+?)\\] is not supported\\. You must specify an explicit PixelFormat","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/VertexElement.cs","lineNumber":637,"sourceCode":"            if (typeof(Half) == type)\n                return PixelFormat.R16_Float;\n\n            if (typeof(Int4) == type)\n                return PixelFormat.R32G32B32A32_UInt;\n            if (typeof(Int3) == type)\n                return PixelFormat.R32G32B32_UInt;\n            if (typeof(int) == type)\n                return PixelFormat.R32_UInt;\n            if (typeof(uint) == type)\n                return PixelFormat.R32_UInt;\n\n            //if (typeof(Bool4) == typeT)\n            //    return PixelFormat.R32G32B32A32_UInt;\n\n            //if (typeof(Bool) == typeT)\n            //    return PixelFormat.R32_UInt;\n\n            throw new NotSupportedException($\"Type [{type.Name}] is not supported. You must specify an explicit PixelFormat\");\n        }\n    }\n\n    #region Serializer\n\n    /// <summary>\n    ///   Provides functionality to serialize and deserialize <see cref=\"VertexElement\"/> objects.\n    /// </summary>\n    internal class Serializer : DataSerializer<VertexElement>\n    {\n        /// <summary>\n        ///   Serializes or deserializes a <see cref=\"VertexElement\"/> object.\n        /// </summary>\n        /// <param name=\"vertexElement\">The object to serialize or deserialize.</param>\n        /// <inheritdoc/>\n        public override void Serialize(ref VertexElement vertexElement, ArchiveMode mode, SerializationStream stream)\n        {\n            if (mode == ArchiveMode.Deserialize)","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/VertexElement.cs#L619-L655","documentation":"ConvertTypeToFormat maps a C# vertex type (float, Vector2, Color, etc.) to a default PixelFormat. If the type has no registered mapping, the library throws NotSupportedException telling the caller to supply an explicit PixelFormat when constructing the VertexElement.","triggerScenarios":"Creating a VertexElement from a custom struct type (e.g. a user-defined half-float struct or Half4 wrapper) without specifying a PixelFormat, so the library must infer the format and fails.","commonSituations":"Custom vertex structs with exotic types (Half, normalized byte vectors) that lack built-in format inference; refactoring a vertex type without updating the format mapping.","solutions":["Pass an explicit PixelFormat, e.g. new VertexElement(\"POSITION\", PixelFormat.R32G32B32_Float)","Change the vertex field to a supported type (float, Vector2/3/4, Color, etc.)"],"exampleFix":"// before\nVertexElement.FromType<MyHalf4Type>(\"TANGENT\") // format inference fails\n// after\nnew VertexElement(\"TANGENT\", 0, PixelFormat.R32G32B32A32_Float)","handlingStrategy":"validation","validationCode":"var supported = new HashSet<Type> { typeof(float), typeof(Vector2), typeof(Vector3), typeof(Vector4), typeof(Color), typeof(byte), typeof(Half) };\nbool FormatInferable(Type t) => supported.Contains(t);","typeGuard":null,"tryCatchPattern":"try { element = VertexElement.FromType<T>(name); } catch (NotSupportedException) { element = new VertexElement(name, 0, explicitFormat); }","preventionTips":["Always pass an explicit PixelFormat for custom vertex types","Restrict vertex struct fields to types with built-in format inference","Map new vertex types to formats when introducing them"],"tags":["graphics","vertex-declaration","pixel-format","unsupported-type"],"backgroundTag":"unsupported-dtype","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}