mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
[monogame] Added BlendState support for BlendMode.Multiply.
This commit is contained in:
parent
59d700ac3f
commit
66392e8cba
@ -48,6 +48,7 @@ namespace Spine {
|
||||
float[] vertices = new float[8];
|
||||
int[] quadTriangles = { 0, 1, 2, 2, 3, 0 };
|
||||
BlendState defaultBlendState;
|
||||
BlendState blendStateMultiply = null;
|
||||
|
||||
Effect effect;
|
||||
public Effect Effect { get { return effect; } set { effect = value; } }
|
||||
@ -86,6 +87,12 @@ namespace Spine {
|
||||
|
||||
public void Begin () {
|
||||
defaultBlendState = premultipliedAlpha ? BlendState.AlphaBlend : BlendState.NonPremultiplied;
|
||||
if (blendStateMultiply == null) {
|
||||
blendStateMultiply = new BlendState();
|
||||
blendStateMultiply.ColorBlendFunction = BlendFunction.Max;
|
||||
blendStateMultiply.ColorSourceBlend = Blend.DestinationColor;
|
||||
blendStateMultiply.ColorDestinationBlend = Blend.Zero;
|
||||
}
|
||||
|
||||
device.RasterizerState = rasterizerState;
|
||||
device.BlendState = defaultBlendState;
|
||||
@ -151,7 +158,18 @@ namespace Spine {
|
||||
}
|
||||
|
||||
// set blend state
|
||||
BlendState blend = slot.Data.BlendMode == BlendMode.Additive ? BlendState.Additive : defaultBlendState;
|
||||
BlendState blend;
|
||||
switch (slot.Data.BlendMode) {
|
||||
case BlendMode.Additive:
|
||||
blend = BlendState.Additive;
|
||||
break;
|
||||
case BlendMode.Multiply:
|
||||
blend = blendStateMultiply;
|
||||
break;
|
||||
default:
|
||||
blend = defaultBlendState;
|
||||
break;
|
||||
}
|
||||
if (device.BlendState != blend) {
|
||||
End();
|
||||
device.BlendState = blend;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user