{"record":{"id":"e474f35e976eebe7","repo":"stride3d/stride","slug":"only-orders-inferior-or-equal-to-5-are-supported","errorCode":null,"errorMessage":"Only orders inferior or equal to 5 are supported","messagePattern":"Only orders inferior or equal to 5 are supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/SphericalHarmonics.cs","lineNumber":37,"sourceCode":"{\n    /// <summary>\n    /// The maximum order supported.\n    /// </summary>\n    public const int MaximumOrder = 5;\n\n    private int order;\n\n    /// <summary>\n    /// The order of calculation of the spherical harmonic.\n    /// </summary>\n    [DataMember(0)]\n    public int Order\n    {\n        get { return order; }\n        internal set\n        {\n            if (order > 5)\n                throw new NotSupportedException(\"Only orders inferior or equal to 5 are supported\");\n\n            order = Math.Max(1, value);\n        }\n    }\n\n    /// <summary>\n    /// Get the coefficients defining the spherical harmonics (the spherical coordinates x{l,m} multiplying the spherical base Y{l,m}).\n    /// </summary>\n    [DataMember(1)]\n    public TDataType[] Coefficients { get; internal set; }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"SphericalHarmonics{TDataType}\"/> class (null, for serialization).\n    /// </summary>\n    internal SphericalHarmonics()\n    {\n    }\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/SphericalHarmonics.cs#L19-L55","documentation":"SphericalHarmonics.Order rejects any value greater than 5 with NotSupportedException, because the implementation only stores coefficients for orders up to 5. Higher-order harmonics are simply not supported by this type, so the setter fails fast instead of truncating silently.","triggerScenarios":"Setting harmonics.Order = 6 or higher, e.g. to match an external lighting solver or a paper's band count; also constructing SphericalHarmonics<T> with order > 5 which flows into the Order setter.","commonSituations":"Porting SH code from libraries supporting higher orders; using precomputed radiance transfer data with more bands; misreading order vs. band count (order L has (L+1)^2 coefficients).","solutions":["Use an order of 5 or less","Split higher-order data and truncate to order 5, accepting the precision loss","Implement a custom SH type if higher orders are truly required"],"exampleFix":"// before\nvar sh = new SphericalHarmonics<Vector3>(8);\n// after\nvar sh = new SphericalHarmonics<Vector3>(Math.Min(5, requestedOrder));","handlingStrategy":"validation","validationCode":"if (order >= 1 && order <= 5) { var sh = new SphericalHarmonics<Vector3>(order); }","typeGuard":"bool IsSupportedShOrder(int o) => o >= 1 && o <= 5;","tryCatchPattern":"try { sh.Order = order; }\ncatch (NotSupportedException ex) { /* fall back to order 5 */ }","preventionTips":["Clamp configured order to <= 5","Remember order L has (L+1)^2 coefficients","Document the order-5 limit wherever SH data is imported"],"tags":["mathematics","spherical-harmonics","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}