Merge branch '3.6' into 3.7-beta

This commit is contained in:
badlogic 2017-09-30 09:51:10 +02:00
commit c1764df4d2
20 changed files with 10439 additions and 10378 deletions

View File

@ -63,7 +63,7 @@
* Added support for clipping.
* SkeletonRenderer now combines the displayed color of the Node (cascaded from all parents) with the skeleton color for tinting.
* Added support for vertex effects. See `RaptorExample.cpp`.
* Added ETC1 support, thanks @halx99!
* Added ETC1 alpha support, thanks @halx99! Does not work when two color tint is enabled.
### Cocos2d-Objc
* Fixed renderer to work with 3.6 changes

View File

@ -88,7 +88,7 @@ void main() {
vec4 texColor = texture2D(texture, v_texCoord);
float alpha = texColor.a * v_light.a;
gl_FragColor.a = alpha;
gl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb;
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
}
);

View File

@ -192,7 +192,7 @@ static bool handlerQueued = false;
unsigned short* triangles = 0;
int trianglesCount = 0;
float r = 0, g = 0, b = 0, a = 0;
float dr = 0, dg = 0, db = 0;
float dr = 0, dg = 0, db = 0, da = _premultipliedAlpha ? 1 : 0;
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
spSlot* slot = _skeleton->drawOrder[i];
if (!slot->attachment) continue;
@ -336,7 +336,7 @@ static bool handlerQueued = false;
dark.r = dr;
dark.g = dg;
dark.b = db;
dark.a = 1;
dark.a = da;
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
spColor lightCopy = light;
spColor darkCopy = dark;
@ -353,7 +353,7 @@ static bool handlerQueued = false;
verts->z = vertex.position.z;
verts->w = vertex.position.w;
verts->color = ((unsigned short)(lightCopy.r * 255))| ((unsigned short)(lightCopy.g * 255)) << 8 | ((unsigned short)(lightCopy.b * 255)) <<16 | ((unsigned short)(lightCopy.a * 255)) << 24;
verts->color2 = ((unsigned short)(darkCopy.r * 255)) | ((unsigned short)(darkCopy.g * 255)) << 8 | ((unsigned short)(darkCopy.b * 255)) << 16 | ((unsigned short)(255)) << 24;
verts->color2 = ((unsigned short)(darkCopy.r * 255)) | ((unsigned short)(darkCopy.g * 255)) << 8 | ((unsigned short)(darkCopy.b * 255)) << 16 | ((unsigned short)(darkCopy.a * 255)) << 24;
}
} else {
@ -366,7 +366,7 @@ static bool handlerQueued = false;
verts->z = vertex.position.z;
verts->w = vertex.position.w;
verts->color = ((unsigned short)(r * 255))| ((unsigned short)(g * 255)) << 8 | ((unsigned short)(b * 255)) <<16 | ((unsigned short)(a * 255)) << 24;
verts->color2 = ((unsigned short)(dr * 255)) | ((unsigned short)(dg * 255)) << 8 | ((unsigned short)(db * 255)) << 16 | ((unsigned short)(255)) << 24;
verts->color2 = ((unsigned short)(dr * 255)) | ((unsigned short)(dg * 255)) << 8 | ((unsigned short)(db * 255)) << 16 | ((unsigned short)(da * 255)) << 24;
verts->u = uvs[i * 2];
verts->v = 1 - uvs[i * 2 + 1];
}

View File

@ -68,10 +68,15 @@ void SkeletonRenderer::initialize () {
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
setupGLProgramState(false);
}
void SkeletonRenderer::setupGLProgramState () {
void SkeletonRenderer::setupGLProgramState (bool twoColorTintEnabled) {
if (twoColorTintEnabled) {
setGLProgramState(SkeletonTwoColorBatch::getInstance()->getTwoColorTintProgramState());
return;
}
Texture2D *texture = nullptr;
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
spSlot* slot = _skeleton->drawOrder[i];
@ -95,7 +100,6 @@ void SkeletonRenderer::setupGLProgramState () {
break;
}
}
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
}
@ -223,6 +227,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
Color4F color;
Color4F darkColor;
float darkPremultipliedAlpha = _premultipliedAlpha ? 255 : 0;
AttachmentVertices* attachmentVertices = nullptr;
TwoColorTrianglesCommand* lastTwoColorTrianglesCommand = nullptr;
for (int i = 0, n = _skeleton->slotsCount; i < n; ++i) {
@ -313,6 +318,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
darkColor.g = 0;
darkColor.b = 0;
}
darkColor.a = darkPremultipliedAlpha;
color.a *= nodeColor.a * _skeleton->color.a * slot->color.a * 255;
// skip rendering if the color of this attachment is 0
@ -478,7 +484,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
vertex->color2.a = 1;
vertex->color2.a = (GLubyte)darkColor.a;
}
} else {
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2) {
@ -494,7 +500,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = 1;
vertex->color2.a = (GLubyte)darkColor.a;
}
}
} else {
@ -524,7 +530,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
vertex->color2.a = 1;
vertex->color2.a = (GLubyte)darkColor.a;
}
} else {
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) {
@ -536,7 +542,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
vertex->color2.r = (GLubyte)darkColor.r;
vertex->color2.g = (GLubyte)darkColor.g;
vertex->color2.b = (GLubyte)darkColor.b;
vertex->color2.a = 1;
vertex->color2.a = (GLubyte)darkColor.a;
}
}
}
@ -737,10 +743,7 @@ bool SkeletonRenderer::setAttachment (const std::string& slotName, const char* a
}
void SkeletonRenderer::setTwoColorTint(bool enabled) {
if (enabled)
setGLProgramState(SkeletonTwoColorBatch::getInstance()->getTwoColorTintProgramState());
else
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
setupGLProgramState(enabled);
}
bool SkeletonRenderer::isTwoColorTint() {

View File

@ -124,11 +124,12 @@ CC_CONSTRUCTOR_ACCESS:
void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
virtual void initialize ();
void setupGLProgramState();
protected:
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
virtual AttachmentVertices* getAttachmentVertices (spRegionAttachment* attachment) const;
virtual AttachmentVertices* getAttachmentVertices (spMeshAttachment* attachment) const;
void setupGLProgramState(bool twoColorTintEnabled);
bool _ownsSkeletonData;
spAtlas* _atlas;

View File

@ -144,7 +144,7 @@ void main() {
vec4 texColor = texture2D(CC_Texture0, v_texCoord);
float alpha = texColor.a * v_light.a;
gl_FragColor.a = alpha;
gl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb;
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
}
);

View File

@ -66,6 +66,7 @@ namespace Spine {
translateMix = data.translateMix;
}
/// <summary>Applies the constraint to the constrained bones.</summary>
public void Apply () {
Update();
}
@ -95,8 +96,8 @@ namespace Spine {
if (setupLength == 0) setupLength = 0.000000001f;
float x = setupLength * bone.a, y = setupLength * bone.c;
float length = (float)Math.Sqrt(x * x + y * y);
if (scale) lengths.Items[i] = setupLength;
spaces.Items[++i] = (lengthSpacing ? Math.Max(0, setupLength + spacing) : spacing) * length / setupLength;
if (scale) lengths.Items[i] = length;
spaces.Items[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
}
} else {
for (int i = 1; i < spacesCount; i++)

View File

@ -78,10 +78,11 @@ public class SkeletonRenderer {
region.computeWorldVertices(slot.getBone(), vertices, 0, 5);
Color color = region.getColor(), slotColor = slot.getColor();
float alpha = a * slotColor.a * color.a * 255;
float multiplier = premultipliedAlpha ? alpha : 255;
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
| ((int)(b * slotColor.b * color.b * alpha) << 16) //
| ((int)(g * slotColor.g * color.g * alpha) << 8) //
| (int)(r * slotColor.r * color.r * alpha));
| ((int)(b * slotColor.b * color.b * multiplier) << 16) //
| ((int)(g * slotColor.g * color.g * multiplier) << 8) //
| (int)(r * slotColor.r * color.r * multiplier));
float[] uvs = region.getUVs();
for (int u = 0, v = 2; u < 8; u += 2, v += 5) {
vertices[v] = c;
@ -173,10 +174,11 @@ public class SkeletonRenderer {
if (texture != null) {
Color slotColor = slot.getColor();
float alpha = a * slotColor.a * color.a * 255;
float multiplier = premultipliedAlpha ? alpha : 255;
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
| ((int)(b * slotColor.b * color.b * alpha) << 16) //
| ((int)(g * slotColor.g * color.g * alpha) << 8) //
| (int)(r * slotColor.r * color.r * alpha));
| ((int)(b * slotColor.b * color.b * multiplier) << 16) //
| ((int)(g * slotColor.g * color.g * multiplier) << 8) //
| (int)(r * slotColor.r * color.r * multiplier));
BlendMode slotBlendMode = slot.data.getBlendMode();
if (slotBlendMode != blendMode) {
@ -238,6 +240,7 @@ public class SkeletonRenderer {
if (vertexEffect != null) vertexEffect.begin(skeleton);
boolean premultipliedAlpha = this.premultipliedAlpha;
int darkPremultipliedAlpha = (premultipliedAlpha ? 255 : 0) << 24;
BlendMode blendMode = null;
int verticesLength = 0;
float[] vertices = null, uvs = null;
@ -284,16 +287,17 @@ public class SkeletonRenderer {
if (texture != null) {
Color lightColor = slot.getColor();
float alpha = a * lightColor.a * color.a * 255;
float multiplier = premultipliedAlpha ? alpha : 255;
float light = NumberUtils.intToFloatColor(((int)alpha << 24) //
| ((int)(b * lightColor.b * color.b * alpha) << 16) //
| ((int)(g * lightColor.g * color.g * alpha) << 8) //
| (int)(r * lightColor.r * color.r * alpha));
| ((int)(b * lightColor.b * color.b * multiplier) << 16) //
| ((int)(g * lightColor.g * color.g * multiplier) << 8) //
| (int)(r * lightColor.r * color.r * multiplier));
Color darkColor = slot.getDarkColor();
if (darkColor == null) darkColor = Color.BLACK;
float dark = NumberUtils.intToFloatColor( //
((int)(b * darkColor.b * color.b * 255) << 16) //
| ((int)(g * darkColor.g * color.g * 255) << 8) //
| (int)(r * darkColor.r * color.r * 255));
float dark = darkColor == null ? 0 : NumberUtils.intToFloatColor(darkPremultipliedAlpha //
| (int)(b * darkColor.b * color.b * multiplier) << 16 //
| (int)(g * darkColor.g * color.g * multiplier) << 8 //
| (int)(r * darkColor.r * color.r * multiplier));
BlendMode slotBlendMode = slot.data.getBlendMode();
if (slotBlendMode != blendMode) {

View File

@ -219,7 +219,7 @@ public class TwoColorPolygonBatch {
+ "{\n" //
+ " vec4 texColor = texture2D(u_texture, v_texCoords);\n" //
+ " gl_FragColor.a = texColor.a * v_light.a;\n" //
+ " gl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark * gl_FragColor.a + texColor.rgb * v_light.rgb;\n" //
+ " gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n" //
+ "}";
ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);

View File

@ -1517,7 +1517,9 @@ declare module spine.webgl {
static SAMPLER: string;
private context;
private vs;
private vsSource;
private fs;
private fsSource;
private program;
private tmp2x2;
private tmp3x3;
@ -1525,6 +1527,8 @@ declare module spine.webgl {
getProgram(): WebGLProgram;
getVertexShader(): string;
getFragmentShader(): string;
getVertexShaderSource(): string;
getFragmentSource(): string;
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, vertexShader: string, fragmentShader: string);
private compile();
private compileShader(type, source);

View File

@ -8136,6 +8136,8 @@ var spine;
this.tmp2x2 = new Float32Array(2 * 2);
this.tmp3x3 = new Float32Array(3 * 3);
this.tmp4x4 = new Float32Array(4 * 4);
this.vsSource = vertexShader;
this.fsSource = fragmentShader;
this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
this.context.addRestorable(this);
this.compile();
@ -8143,6 +8145,8 @@ var spine;
Shader.prototype.getProgram = function () { return this.program; };
Shader.prototype.getVertexShader = function () { return this.vertexShader; };
Shader.prototype.getFragmentShader = function () { return this.fragmentShader; };
Shader.prototype.getVertexShaderSource = function () { return this.vsSource; };
Shader.prototype.getFragmentSource = function () { return this.fsSource; };
Shader.prototype.compile = function () {
var gl = this.context.gl;
try {
@ -8258,7 +8262,7 @@ var spine;
};
Shader.newTwoColoredTextured = function (context) {
var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR2 + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_light;\n\t\t\t\tvarying vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_light = " + Shader.COLOR + ";\n\t\t\t\t\tv_dark = " + Shader.COLOR2 + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tfloat alpha = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.a = alpha;\n\t\t\t\t\tgl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t";
var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tgl_FragColor.a = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t";
return new Shader(context, vs, fs);
};
Shader.newColored = function (context) {
@ -8893,9 +8897,18 @@ var spine;
}
var darkColor = this.tempColor2;
if (slot.darkColor == null)
darkColor.set(0, 0, 0, 1);
else
darkColor.setFromColor(slot.darkColor);
darkColor.set(0, 0, 0, 1.0);
else {
if (premultipliedAlpha) {
darkColor.r = slot.darkColor.r * finalColor.a;
darkColor.g = slot.darkColor.g * finalColor.a;
darkColor.b = slot.darkColor.b * finalColor.a;
}
else {
darkColor.setFromColor(slot.darkColor);
}
darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
}
var slotBlendMode = slot.data.blendMode;
if (slotBlendMode != blendMode) {
blendMode = slotBlendMode;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1486,7 +1486,9 @@ declare module spine.webgl {
static SAMPLER: string;
private context;
private vs;
private vsSource;
private fs;
private fsSource;
private program;
private tmp2x2;
private tmp3x3;
@ -1494,6 +1496,8 @@ declare module spine.webgl {
getProgram(): WebGLProgram;
getVertexShader(): string;
getFragmentShader(): string;
getVertexShaderSource(): string;
getFragmentSource(): string;
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, vertexShader: string, fragmentShader: string);
private compile();
private compileShader(type, source);

View File

@ -7881,6 +7881,8 @@ var spine;
this.tmp2x2 = new Float32Array(2 * 2);
this.tmp3x3 = new Float32Array(3 * 3);
this.tmp4x4 = new Float32Array(4 * 4);
this.vsSource = vertexShader;
this.fsSource = fragmentShader;
this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
this.context.addRestorable(this);
this.compile();
@ -7888,6 +7890,8 @@ var spine;
Shader.prototype.getProgram = function () { return this.program; };
Shader.prototype.getVertexShader = function () { return this.vertexShader; };
Shader.prototype.getFragmentShader = function () { return this.fragmentShader; };
Shader.prototype.getVertexShaderSource = function () { return this.vsSource; };
Shader.prototype.getFragmentSource = function () { return this.fsSource; };
Shader.prototype.compile = function () {
var gl = this.context.gl;
try {
@ -8003,7 +8007,7 @@ var spine;
};
Shader.newTwoColoredTextured = function (context) {
var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR2 + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_light;\n\t\t\t\tvarying vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_light = " + Shader.COLOR + ";\n\t\t\t\t\tv_dark = " + Shader.COLOR2 + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tfloat alpha = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.a = alpha;\n\t\t\t\t\tgl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t";
var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tgl_FragColor.a = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t";
return new Shader(context, vs, fs);
};
Shader.newColored = function (context) {
@ -8638,9 +8642,18 @@ var spine;
}
var darkColor = this.tempColor2;
if (slot.darkColor == null)
darkColor.set(0, 0, 0, 1);
else
darkColor.setFromColor(slot.darkColor);
darkColor.set(0, 0, 0, 1.0);
else {
if (premultipliedAlpha) {
darkColor.r = slot.darkColor.r * finalColor.a;
darkColor.g = slot.darkColor.g * finalColor.a;
darkColor.b = slot.darkColor.b * finalColor.a;
}
else {
darkColor.setFromColor(slot.darkColor);
}
darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
}
var slotBlendMode = slot.data.blendMode;
if (slotBlendMode != blendMode) {
blendMode = slotBlendMode;

File diff suppressed because one or more lines are too long

View File

@ -253,9 +253,8 @@ module spine.webgl {
void main () {
vec4 texColor = texture2D(u_texture, v_texCoords);
float alpha = texColor.a * v_light.a;
gl_FragColor.a = alpha;
gl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb;
gl_FragColor.a = texColor.a * v_light.a;
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
}
`;

View File

@ -122,8 +122,18 @@ module spine.webgl {
finalColor.b *= finalColor.a;
}
let darkColor = this.tempColor2;
if (slot.darkColor == null) darkColor.set(0, 0, 0, 1);
else darkColor.setFromColor(slot.darkColor);
if (slot.darkColor == null)
darkColor.set(0, 0, 0, 1.0);
else {
if (premultipliedAlpha) {
darkColor.r = slot.darkColor.r * finalColor.a;
darkColor.g = slot.darkColor.g * finalColor.a;
darkColor.b = slot.darkColor.b * finalColor.a;
} else {
darkColor.setFromColor(slot.darkColor);
}
darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
}
let slotBlendMode = slot.data.blendMode;
if (slotBlendMode != blendMode) {