mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-11 09:38:44 +08:00
Additive blending for spine-csharp and spine-xna.
This commit is contained in:
parent
a511e267d2
commit
734505c91c
@ -127,7 +127,10 @@ namespace Spine {
|
||||
}
|
||||
|
||||
if (slotMap.ContainsKey("attachment"))
|
||||
slotData.AttachmentName = (String)slotMap["attachment"];
|
||||
slotData.AttachmentName = (String)slotMap["attachment"];
|
||||
|
||||
if (slotMap.ContainsKey("additive"))
|
||||
slotData.AdditiveBlending = (bool)slotMap["additive"];
|
||||
|
||||
skeletonData.AddSlot(slotData);
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ namespace Spine {
|
||||
public float A { get; set; }
|
||||
/** @param attachmentName May be null. */
|
||||
public String AttachmentName { get; set; }
|
||||
public bool AdditiveBlending { get; set; }
|
||||
|
||||
public SlotData (String name, BoneData boneData) {
|
||||
if (name == null) throw new ArgumentNullException("name cannot be null.");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -34,7 +34,7 @@ namespace Spine {
|
||||
SpriteBatcher batcher;
|
||||
BasicEffect effect;
|
||||
RasterizerState rasterizerState;
|
||||
public BlendState BlendState { get; set; }
|
||||
public bool PremultipliedAlpha { get; set; }
|
||||
float[] vertices = new float[8];
|
||||
|
||||
public SkeletonRenderer (GraphicsDevice device) {
|
||||
@ -51,14 +51,12 @@ namespace Spine {
|
||||
rasterizerState = new RasterizerState();
|
||||
rasterizerState.CullMode = CullMode.None;
|
||||
|
||||
BlendState = BlendState.AlphaBlend;
|
||||
|
||||
Bone.yDown = true;
|
||||
}
|
||||
|
||||
public void Begin () {
|
||||
device.RasterizerState = rasterizerState;
|
||||
device.BlendState = BlendState;
|
||||
device.BlendState = BlendState.AlphaBlend;
|
||||
|
||||
effect.Projection = Matrix.CreateOrthographicOffCenter(0, device.Viewport.Width, device.Viewport.Height, 0, 1, 0);
|
||||
}
|
||||
@ -71,11 +69,19 @@ namespace Spine {
|
||||
}
|
||||
|
||||
public void Draw (Skeleton skeleton) {
|
||||
Console.WriteLine();
|
||||
|
||||
List<Slot> drawOrder = skeleton.DrawOrder;
|
||||
for (int i = 0, n = drawOrder.Count; i < n; i++) {
|
||||
Slot slot = drawOrder[i];
|
||||
RegionAttachment regionAttachment = slot.Attachment as RegionAttachment;
|
||||
if (regionAttachment != null) {
|
||||
BlendState blend = slot.Data.AdditiveBlending ? BlendState.Additive : BlendState.AlphaBlend;
|
||||
if (device.BlendState != blend) {
|
||||
End();
|
||||
device.BlendState = blend;
|
||||
}
|
||||
|
||||
SpriteBatchItem item = batcher.CreateBatchItem();
|
||||
AtlasRegion region = (AtlasRegion)regionAttachment.RendererObject;
|
||||
item.Texture = (Texture2D)region.page.rendererObject;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user