MoonWorks/src/Graphics/State/ColorTargetBlendState.cs

122 lines
4.7 KiB
C#
Raw Normal View History

using RefreshCS;
namespace MoonWorks.Graphics
{
public struct ColorTargetBlendState
{
2021-02-24 20:43:35 +00:00
/// <summary>
/// If disabled, no blending will occur.
/// </summary>
public bool BlendEnable;
2021-02-24 20:43:35 +00:00
/// <summary>
/// Selects which blend operation to use with alpha values.
/// </summary>
2021-01-27 01:39:20 +00:00
public BlendOp AlphaBlendOp;
2021-02-24 20:43:35 +00:00
/// <summary>
/// Selects which blend operation to use with color values.
/// </summary>
2021-01-27 01:39:20 +00:00
public BlendOp ColorBlendOp;
2021-02-24 20:43:35 +00:00
/// <summary>
/// Specifies which of the RGBA components are enabled for writing.
/// </summary>
2021-01-27 01:39:20 +00:00
public ColorComponentFlags ColorWriteMask;
2021-02-24 20:43:35 +00:00
/// <summary>
/// Selects which blend factor is used to determine the alpha destination factor.
/// </summary>
2021-01-27 01:39:20 +00:00
public BlendFactor DestinationAlphaBlendFactor;
2021-02-24 20:43:35 +00:00
/// <summary>
/// Selects which blend factor is used to determine the color destination factor.
/// </summary>
2021-01-27 01:39:20 +00:00
public BlendFactor DestinationColorBlendFactor;
2021-02-24 20:43:35 +00:00
/// <summary>
/// Selects which blend factor is used to determine the alpha source factor.
/// </summary>
2021-01-27 01:39:20 +00:00
public BlendFactor SourceAlphaBlendFactor;
2021-02-24 20:43:35 +00:00
/// <summary>
/// Selects which blend factor is used to determine the color source factor.
/// </summary>
2021-01-27 01:39:20 +00:00
public BlendFactor SourceColorBlendFactor;
public static readonly ColorTargetBlendState Additive = new ColorTargetBlendState
{
BlendEnable = true,
2021-01-27 01:39:20 +00:00
AlphaBlendOp = BlendOp.Add,
ColorBlendOp = BlendOp.Add,
ColorWriteMask = ColorComponentFlags.RGBA,
SourceColorBlendFactor = BlendFactor.SourceAlpha,
SourceAlphaBlendFactor = BlendFactor.SourceAlpha,
DestinationColorBlendFactor = BlendFactor.One,
DestinationAlphaBlendFactor = BlendFactor.One
};
public static readonly ColorTargetBlendState AlphaBlend = new ColorTargetBlendState
{
BlendEnable = true,
2021-01-27 01:39:20 +00:00
AlphaBlendOp = BlendOp.Add,
ColorBlendOp = BlendOp.Add,
ColorWriteMask = ColorComponentFlags.RGBA,
SourceColorBlendFactor = BlendFactor.One,
SourceAlphaBlendFactor = BlendFactor.One,
DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha,
DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha
};
public static readonly ColorTargetBlendState NonPremultiplied = new ColorTargetBlendState
{
BlendEnable = true,
2021-01-27 01:39:20 +00:00
AlphaBlendOp = BlendOp.Add,
ColorBlendOp = BlendOp.Add,
ColorWriteMask = ColorComponentFlags.RGBA,
SourceColorBlendFactor = BlendFactor.SourceAlpha,
SourceAlphaBlendFactor = BlendFactor.SourceAlpha,
DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha,
DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha
};
public static readonly ColorTargetBlendState Opaque = new ColorTargetBlendState
{
BlendEnable = true,
2021-01-27 01:39:20 +00:00
AlphaBlendOp = BlendOp.Add,
ColorBlendOp = BlendOp.Add,
ColorWriteMask = ColorComponentFlags.RGBA,
SourceColorBlendFactor = BlendFactor.One,
SourceAlphaBlendFactor = BlendFactor.One,
DestinationColorBlendFactor = BlendFactor.Zero,
DestinationAlphaBlendFactor = BlendFactor.Zero
};
public static readonly ColorTargetBlendState None = new ColorTargetBlendState
{
BlendEnable = false,
2021-01-27 01:39:20 +00:00
ColorWriteMask = ColorComponentFlags.RGBA
};
2021-02-09 02:10:02 +00:00
public static readonly ColorTargetBlendState Disable = new ColorTargetBlendState
{
BlendEnable = false,
ColorWriteMask = ColorComponentFlags.None
};
public Refresh.ColorTargetBlendState ToRefreshColorTargetBlendState()
{
return new Refresh.ColorTargetBlendState
{
blendEnable = Conversions.BoolToByte(BlendEnable),
2021-01-27 01:39:20 +00:00
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
};
}
}
}