using RefreshCS; namespace MoonWorks.Graphics { /// /// Defines how color blending will be performed in a GraphicsPipeline. /// public struct ColorAttachmentBlendState { /// /// If disabled, no blending will occur. /// public bool BlendEnable; /// /// Selects which blend operation to use with alpha values. /// public BlendOp AlphaBlendOp; /// /// Selects which blend operation to use with color values. /// public BlendOp ColorBlendOp; /// /// Specifies which of the RGBA components are enabled for writing. /// public ColorComponentFlags ColorWriteMask; /// /// Selects which blend factor is used to determine the alpha destination factor. /// public BlendFactor DestinationAlphaBlendFactor; /// /// Selects which blend factor is used to determine the color destination factor. /// public BlendFactor DestinationColorBlendFactor; /// /// Selects which blend factor is used to determine the alpha source factor. /// public BlendFactor SourceAlphaBlendFactor; /// /// Selects which blend factor is used to determine the color source factor. /// public BlendFactor SourceColorBlendFactor; public static readonly ColorAttachmentBlendState Additive = new ColorAttachmentBlendState { BlendEnable = true, AlphaBlendOp = BlendOp.Add, ColorBlendOp = BlendOp.Add, ColorWriteMask = ColorComponentFlags.RGBA, SourceColorBlendFactor = BlendFactor.SourceAlpha, SourceAlphaBlendFactor = BlendFactor.SourceAlpha, DestinationColorBlendFactor = BlendFactor.One, DestinationAlphaBlendFactor = BlendFactor.One }; public static readonly ColorAttachmentBlendState AlphaBlend = new ColorAttachmentBlendState { BlendEnable = true, AlphaBlendOp = BlendOp.Add, ColorBlendOp = BlendOp.Add, ColorWriteMask = ColorComponentFlags.RGBA, SourceColorBlendFactor = BlendFactor.One, SourceAlphaBlendFactor = BlendFactor.One, DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha, DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha }; public static readonly ColorAttachmentBlendState NonPremultiplied = new ColorAttachmentBlendState { BlendEnable = true, AlphaBlendOp = BlendOp.Add, ColorBlendOp = BlendOp.Add, ColorWriteMask = ColorComponentFlags.RGBA, SourceColorBlendFactor = BlendFactor.SourceAlpha, SourceAlphaBlendFactor = BlendFactor.SourceAlpha, DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha, DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha }; public static readonly ColorAttachmentBlendState Opaque = new ColorAttachmentBlendState { BlendEnable = true, AlphaBlendOp = BlendOp.Add, ColorBlendOp = BlendOp.Add, ColorWriteMask = ColorComponentFlags.RGBA, SourceColorBlendFactor = BlendFactor.One, SourceAlphaBlendFactor = BlendFactor.One, DestinationColorBlendFactor = BlendFactor.Zero, DestinationAlphaBlendFactor = BlendFactor.Zero }; public static readonly ColorAttachmentBlendState None = new ColorAttachmentBlendState { BlendEnable = false, ColorWriteMask = ColorComponentFlags.RGBA }; public static readonly ColorAttachmentBlendState Disable = new ColorAttachmentBlendState { BlendEnable = false, ColorWriteMask = ColorComponentFlags.None }; public Refresh.ColorAttachmentBlendState ToRefresh() { return new Refresh.ColorAttachmentBlendState { blendEnable = Conversions.BoolToByte(BlendEnable), alphaBlendOp = (Refresh.BlendOp) AlphaBlendOp, colorBlendOp = (Refresh.BlendOp) ColorBlendOp, colorWriteMask = (Refresh.ColorComponentFlags) ColorWriteMask, destinationAlphaBlendFactor = (Refresh.BlendFactor) DestinationAlphaBlendFactor, destinationColorBlendFactor = (Refresh.BlendFactor) DestinationColorBlendFactor, sourceAlphaBlendFactor = (Refresh.BlendFactor) SourceAlphaBlendFactor, sourceColorBlendFactor = (Refresh.BlendFactor) SourceColorBlendFactor }; } } }