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