{"record":{"id":"b09896baad22bf82","repo":"stride3d/stride","slug":"static-samplers-can-only-have-opaque-black-opaque-white-or","errorCode":null,"errorMessage":"Static Samplers can only have opaque black, opaque white or transparent black as border color.","messagePattern":"Static Samplers can only have opaque black, opaque white or transparent black as border color\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/PipelineState.Direct3D12.cs","lineNumber":692,"sourceCode":"            //\n            // Converts a Color4 to its corresponding StaticBorderColor for a Sampler's border color.\n            //\n            static StaticBorderColor ConvertToStaticBorderColor(Color4 color)\n            {\n                if (color == Color4.Black)\n                {\n                    return StaticBorderColor.OpaqueBlack;\n                }\n                else if (color == Color4.White)\n                {\n                    return StaticBorderColor.OpaqueWhite;\n                }\n                else if (color == Color4.TransparentBlack)\n                {\n                    return StaticBorderColor.TransparentBlack;\n                }\n\n                throw new NotSupportedException(\"Static Samplers can only have opaque black, opaque white or transparent black as border color.\");\n            }\n\n            //\n            // Returns the Direct3D 12 Shader Visibility for a Stride's ShaderStage.\n            //\n            static ShaderVisibility GetShaderVisibilityForStage(ShaderStage stage)\n            {\n                return stage switch\n                {\n                    ShaderStage.Vertex => ShaderVisibility.Vertex,\n                    ShaderStage.Hull => ShaderVisibility.Hull,\n                    ShaderStage.Domain => ShaderVisibility.Domain,\n                    ShaderStage.Geometry => ShaderVisibility.Geometry,\n                    ShaderStage.Pixel => ShaderVisibility.Pixel,\n                    ShaderStage.Compute => ShaderVisibility.All,\n\n                    _ => throw new ArgumentOutOfRangeException(nameof(stage), stage, \"Invalid ShaderStage.\")\n                };","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/PipelineState.Direct3D12.cs#L674-L710","documentation":"D3D12 static samplers may only use the fixed border colors the API can encode (OpaqueBlack, OpaqueWhite, TransparentBlack). When the backend tries to map a sampler's BorderColor to a StaticBorderColor, any other color hits the final throw of NotSupportedException.","triggerScenarios":"SamplerStateDescription with a custom BorderColor (e.g. Color4(1,0,0,1) or any non-black/white value) included in a PipelineStateDescription's static samplers.","commonSituations":"Clamp/border sampling with a tinted border color configured by artists; copying sampler settings from an engine/backend that supports arbitrary border colors.","solutions":["Change the sampler border color to one of: OpaqueBlack, OpaqueWhite, or TransparentBlack","Move the sampler out of static samplers into a dynamically-bound sampler descriptor if a custom border color is required","Default to OpaqueBlack/TransparentBlack unless a specific border look is needed"],"exampleFix":"// before\nvar sampler = new SamplerStateDescription { BorderColor = new Color4(1f, 0f, 0f, 1f) };\n// after\nvar sampler = new SamplerStateDescription { BorderColor = Color4.TransparentBlack };","handlingStrategy":"validation","validationCode":"if (sampler.BorderColor is not (Color4.Black or Color4.White or Color4.TransparentBlack)) throw new InvalidOperationException(\"Static sampler border color must be opaque black/white or transparent black\");","typeGuard":"bool HasStaticBorderColor(Color4 c) => c.Equals(Color4.Black) || c.Equals(Color4.White) || c.Equals(Color4.TransparentBlack);","tryCatchPattern":"try { state = PipelineState.New(device, desc); } catch (NotSupportedException) { /* non-static border color */ throw; }","preventionTips":["Use only the three D3D12 static border colors in sampler descriptions","For custom border colors, use dynamically bound samplers instead of static samplers"],"tags":["direct3d12","sampler","unsupported"],"backgroundTag":"unsupported-config-value","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"}