mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Merge branch '3.6' into 3.7-beta
This commit is contained in:
commit
c1764df4d2
@ -63,7 +63,7 @@
|
|||||||
* Added support for clipping.
|
* Added support for clipping.
|
||||||
* SkeletonRenderer now combines the displayed color of the Node (cascaded from all parents) with the skeleton color for tinting.
|
* 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 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
|
### Cocos2d-Objc
|
||||||
* Fixed renderer to work with 3.6 changes
|
* Fixed renderer to work with 3.6 changes
|
||||||
|
|||||||
@ -88,7 +88,7 @@ void main() {
|
|||||||
vec4 texColor = texture2D(texture, v_texCoord);
|
vec4 texColor = texture2D(texture, v_texCoord);
|
||||||
float alpha = texColor.a * v_light.a;
|
float alpha = texColor.a * v_light.a;
|
||||||
gl_FragColor.a = alpha;
|
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;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -192,7 +192,7 @@ static bool handlerQueued = false;
|
|||||||
unsigned short* triangles = 0;
|
unsigned short* triangles = 0;
|
||||||
int trianglesCount = 0;
|
int trianglesCount = 0;
|
||||||
float r = 0, g = 0, b = 0, a = 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++) {
|
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
|
||||||
spSlot* slot = _skeleton->drawOrder[i];
|
spSlot* slot = _skeleton->drawOrder[i];
|
||||||
if (!slot->attachment) continue;
|
if (!slot->attachment) continue;
|
||||||
@ -336,7 +336,7 @@ static bool handlerQueued = false;
|
|||||||
dark.r = dr;
|
dark.r = dr;
|
||||||
dark.g = dg;
|
dark.g = dg;
|
||||||
dark.b = db;
|
dark.b = db;
|
||||||
dark.a = 1;
|
dark.a = da;
|
||||||
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
||||||
spColor lightCopy = light;
|
spColor lightCopy = light;
|
||||||
spColor darkCopy = dark;
|
spColor darkCopy = dark;
|
||||||
@ -353,7 +353,7 @@ static bool handlerQueued = false;
|
|||||||
verts->z = vertex.position.z;
|
verts->z = vertex.position.z;
|
||||||
verts->w = vertex.position.w;
|
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->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 {
|
} else {
|
||||||
@ -366,7 +366,7 @@ static bool handlerQueued = false;
|
|||||||
verts->z = vertex.position.z;
|
verts->z = vertex.position.z;
|
||||||
verts->w = vertex.position.w;
|
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->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->u = uvs[i * 2];
|
||||||
verts->v = 1 - uvs[i * 2 + 1];
|
verts->v = 1 - uvs[i * 2 + 1];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,10 +68,15 @@ void SkeletonRenderer::initialize () {
|
|||||||
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||||
setOpacityModifyRGB(true);
|
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;
|
Texture2D *texture = nullptr;
|
||||||
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
|
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
|
||||||
spSlot* slot = _skeleton->drawOrder[i];
|
spSlot* slot = _skeleton->drawOrder[i];
|
||||||
@ -95,7 +100,6 @@ void SkeletonRenderer::setupGLProgramState () {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
|
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 color;
|
||||||
Color4F darkColor;
|
Color4F darkColor;
|
||||||
|
float darkPremultipliedAlpha = _premultipliedAlpha ? 255 : 0;
|
||||||
AttachmentVertices* attachmentVertices = nullptr;
|
AttachmentVertices* attachmentVertices = nullptr;
|
||||||
TwoColorTrianglesCommand* lastTwoColorTrianglesCommand = nullptr;
|
TwoColorTrianglesCommand* lastTwoColorTrianglesCommand = nullptr;
|
||||||
for (int i = 0, n = _skeleton->slotsCount; i < n; ++i) {
|
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.g = 0;
|
||||||
darkColor.b = 0;
|
darkColor.b = 0;
|
||||||
}
|
}
|
||||||
|
darkColor.a = darkPremultipliedAlpha;
|
||||||
|
|
||||||
color.a *= nodeColor.a * _skeleton->color.a * slot->color.a * 255;
|
color.a *= nodeColor.a * _skeleton->color.a * slot->color.a * 255;
|
||||||
// skip rendering if the color of this attachment is 0
|
// 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.r = (GLubyte)(darkCopy.r * 255);
|
||||||
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
|
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
|
||||||
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
|
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
|
||||||
vertex->color2.a = 1;
|
vertex->color2.a = (GLubyte)darkColor.a;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2) {
|
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.r = (GLubyte)darkColor.r;
|
||||||
vertex->color2.g = (GLubyte)darkColor.g;
|
vertex->color2.g = (GLubyte)darkColor.g;
|
||||||
vertex->color2.b = (GLubyte)darkColor.b;
|
vertex->color2.b = (GLubyte)darkColor.b;
|
||||||
vertex->color2.a = 1;
|
vertex->color2.a = (GLubyte)darkColor.a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -524,7 +530,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
|
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
|
||||||
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
|
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
|
||||||
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
|
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
|
||||||
vertex->color2.a = 1;
|
vertex->color2.a = (GLubyte)darkColor.a;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) {
|
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.r = (GLubyte)darkColor.r;
|
||||||
vertex->color2.g = (GLubyte)darkColor.g;
|
vertex->color2.g = (GLubyte)darkColor.g;
|
||||||
vertex->color2.b = (GLubyte)darkColor.b;
|
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) {
|
void SkeletonRenderer::setTwoColorTint(bool enabled) {
|
||||||
if (enabled)
|
setupGLProgramState(enabled);
|
||||||
setGLProgramState(SkeletonTwoColorBatch::getInstance()->getTwoColorTintProgramState());
|
|
||||||
else
|
|
||||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletonRenderer::isTwoColorTint() {
|
bool SkeletonRenderer::isTwoColorTint() {
|
||||||
|
|||||||
@ -124,11 +124,12 @@ CC_CONSTRUCTOR_ACCESS:
|
|||||||
void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
||||||
|
|
||||||
virtual void initialize ();
|
virtual void initialize ();
|
||||||
void setupGLProgramState();
|
|
||||||
protected:
|
protected:
|
||||||
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
|
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
|
||||||
virtual AttachmentVertices* getAttachmentVertices (spRegionAttachment* attachment) const;
|
virtual AttachmentVertices* getAttachmentVertices (spRegionAttachment* attachment) const;
|
||||||
virtual AttachmentVertices* getAttachmentVertices (spMeshAttachment* attachment) const;
|
virtual AttachmentVertices* getAttachmentVertices (spMeshAttachment* attachment) const;
|
||||||
|
void setupGLProgramState(bool twoColorTintEnabled);
|
||||||
|
|
||||||
bool _ownsSkeletonData;
|
bool _ownsSkeletonData;
|
||||||
spAtlas* _atlas;
|
spAtlas* _atlas;
|
||||||
|
|||||||
@ -144,7 +144,7 @@ void main() {
|
|||||||
vec4 texColor = texture2D(CC_Texture0, v_texCoord);
|
vec4 texColor = texture2D(CC_Texture0, v_texCoord);
|
||||||
float alpha = texColor.a * v_light.a;
|
float alpha = texColor.a * v_light.a;
|
||||||
gl_FragColor.a = alpha;
|
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;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,7 @@ namespace Spine {
|
|||||||
translateMix = data.translateMix;
|
translateMix = data.translateMix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Applies the constraint to the constrained bones.</summary>
|
||||||
public void Apply () {
|
public void Apply () {
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
@ -95,8 +96,8 @@ namespace Spine {
|
|||||||
if (setupLength == 0) setupLength = 0.000000001f;
|
if (setupLength == 0) setupLength = 0.000000001f;
|
||||||
float x = setupLength * bone.a, y = setupLength * bone.c;
|
float x = setupLength * bone.a, y = setupLength * bone.c;
|
||||||
float length = (float)Math.Sqrt(x * x + y * y);
|
float length = (float)Math.Sqrt(x * x + y * y);
|
||||||
if (scale) lengths.Items[i] = setupLength;
|
if (scale) lengths.Items[i] = length;
|
||||||
spaces.Items[++i] = (lengthSpacing ? Math.Max(0, setupLength + spacing) : spacing) * length / setupLength;
|
spaces.Items[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 1; i < spacesCount; i++)
|
for (int i = 1; i < spacesCount; i++)
|
||||||
|
|||||||
@ -78,10 +78,11 @@ public class SkeletonRenderer {
|
|||||||
region.computeWorldVertices(slot.getBone(), vertices, 0, 5);
|
region.computeWorldVertices(slot.getBone(), vertices, 0, 5);
|
||||||
Color color = region.getColor(), slotColor = slot.getColor();
|
Color color = region.getColor(), slotColor = slot.getColor();
|
||||||
float alpha = a * slotColor.a * color.a * 255;
|
float alpha = a * slotColor.a * color.a * 255;
|
||||||
|
float multiplier = premultipliedAlpha ? alpha : 255;
|
||||||
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
||||||
| ((int)(b * slotColor.b * color.b * alpha) << 16) //
|
| ((int)(b * slotColor.b * color.b * multiplier) << 16) //
|
||||||
| ((int)(g * slotColor.g * color.g * alpha) << 8) //
|
| ((int)(g * slotColor.g * color.g * multiplier) << 8) //
|
||||||
| (int)(r * slotColor.r * color.r * alpha));
|
| (int)(r * slotColor.r * color.r * multiplier));
|
||||||
float[] uvs = region.getUVs();
|
float[] uvs = region.getUVs();
|
||||||
for (int u = 0, v = 2; u < 8; u += 2, v += 5) {
|
for (int u = 0, v = 2; u < 8; u += 2, v += 5) {
|
||||||
vertices[v] = c;
|
vertices[v] = c;
|
||||||
@ -173,10 +174,11 @@ public class SkeletonRenderer {
|
|||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
Color slotColor = slot.getColor();
|
Color slotColor = slot.getColor();
|
||||||
float alpha = a * slotColor.a * color.a * 255;
|
float alpha = a * slotColor.a * color.a * 255;
|
||||||
|
float multiplier = premultipliedAlpha ? alpha : 255;
|
||||||
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
||||||
| ((int)(b * slotColor.b * color.b * alpha) << 16) //
|
| ((int)(b * slotColor.b * color.b * multiplier) << 16) //
|
||||||
| ((int)(g * slotColor.g * color.g * alpha) << 8) //
|
| ((int)(g * slotColor.g * color.g * multiplier) << 8) //
|
||||||
| (int)(r * slotColor.r * color.r * alpha));
|
| (int)(r * slotColor.r * color.r * multiplier));
|
||||||
|
|
||||||
BlendMode slotBlendMode = slot.data.getBlendMode();
|
BlendMode slotBlendMode = slot.data.getBlendMode();
|
||||||
if (slotBlendMode != blendMode) {
|
if (slotBlendMode != blendMode) {
|
||||||
@ -238,6 +240,7 @@ public class SkeletonRenderer {
|
|||||||
if (vertexEffect != null) vertexEffect.begin(skeleton);
|
if (vertexEffect != null) vertexEffect.begin(skeleton);
|
||||||
|
|
||||||
boolean premultipliedAlpha = this.premultipliedAlpha;
|
boolean premultipliedAlpha = this.premultipliedAlpha;
|
||||||
|
int darkPremultipliedAlpha = (premultipliedAlpha ? 255 : 0) << 24;
|
||||||
BlendMode blendMode = null;
|
BlendMode blendMode = null;
|
||||||
int verticesLength = 0;
|
int verticesLength = 0;
|
||||||
float[] vertices = null, uvs = null;
|
float[] vertices = null, uvs = null;
|
||||||
@ -284,16 +287,17 @@ public class SkeletonRenderer {
|
|||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
Color lightColor = slot.getColor();
|
Color lightColor = slot.getColor();
|
||||||
float alpha = a * lightColor.a * color.a * 255;
|
float alpha = a * lightColor.a * color.a * 255;
|
||||||
|
float multiplier = premultipliedAlpha ? alpha : 255;
|
||||||
float light = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
float light = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
||||||
| ((int)(b * lightColor.b * color.b * alpha) << 16) //
|
| ((int)(b * lightColor.b * color.b * multiplier) << 16) //
|
||||||
| ((int)(g * lightColor.g * color.g * alpha) << 8) //
|
| ((int)(g * lightColor.g * color.g * multiplier) << 8) //
|
||||||
| (int)(r * lightColor.r * color.r * alpha));
|
| (int)(r * lightColor.r * color.r * multiplier));
|
||||||
Color darkColor = slot.getDarkColor();
|
Color darkColor = slot.getDarkColor();
|
||||||
if (darkColor == null) darkColor = Color.BLACK;
|
if (darkColor == null) darkColor = Color.BLACK;
|
||||||
float dark = NumberUtils.intToFloatColor( //
|
float dark = darkColor == null ? 0 : NumberUtils.intToFloatColor(darkPremultipliedAlpha //
|
||||||
((int)(b * darkColor.b * color.b * 255) << 16) //
|
| (int)(b * darkColor.b * color.b * multiplier) << 16 //
|
||||||
| ((int)(g * darkColor.g * color.g * 255) << 8) //
|
| (int)(g * darkColor.g * color.g * multiplier) << 8 //
|
||||||
| (int)(r * darkColor.r * color.r * 255));
|
| (int)(r * darkColor.r * color.r * multiplier));
|
||||||
|
|
||||||
BlendMode slotBlendMode = slot.data.getBlendMode();
|
BlendMode slotBlendMode = slot.data.getBlendMode();
|
||||||
if (slotBlendMode != blendMode) {
|
if (slotBlendMode != blendMode) {
|
||||||
|
|||||||
@ -219,7 +219,7 @@ public class TwoColorPolygonBatch {
|
|||||||
+ "{\n" //
|
+ "{\n" //
|
||||||
+ " vec4 texColor = texture2D(u_texture, v_texCoords);\n" //
|
+ " vec4 texColor = texture2D(u_texture, v_texCoords);\n" //
|
||||||
+ " gl_FragColor.a = texColor.a * v_light.a;\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);
|
ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);
|
||||||
|
|||||||
4
spine-ts/build/spine-all.d.ts
vendored
4
spine-ts/build/spine-all.d.ts
vendored
@ -1517,7 +1517,9 @@ declare module spine.webgl {
|
|||||||
static SAMPLER: string;
|
static SAMPLER: string;
|
||||||
private context;
|
private context;
|
||||||
private vs;
|
private vs;
|
||||||
|
private vsSource;
|
||||||
private fs;
|
private fs;
|
||||||
|
private fsSource;
|
||||||
private program;
|
private program;
|
||||||
private tmp2x2;
|
private tmp2x2;
|
||||||
private tmp3x3;
|
private tmp3x3;
|
||||||
@ -1525,6 +1527,8 @@ declare module spine.webgl {
|
|||||||
getProgram(): WebGLProgram;
|
getProgram(): WebGLProgram;
|
||||||
getVertexShader(): string;
|
getVertexShader(): string;
|
||||||
getFragmentShader(): string;
|
getFragmentShader(): string;
|
||||||
|
getVertexShaderSource(): string;
|
||||||
|
getFragmentSource(): string;
|
||||||
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, vertexShader: string, fragmentShader: string);
|
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, vertexShader: string, fragmentShader: string);
|
||||||
private compile();
|
private compile();
|
||||||
private compileShader(type, source);
|
private compileShader(type, source);
|
||||||
|
|||||||
@ -8136,6 +8136,8 @@ var spine;
|
|||||||
this.tmp2x2 = new Float32Array(2 * 2);
|
this.tmp2x2 = new Float32Array(2 * 2);
|
||||||
this.tmp3x3 = new Float32Array(3 * 3);
|
this.tmp3x3 = new Float32Array(3 * 3);
|
||||||
this.tmp4x4 = new Float32Array(4 * 4);
|
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 = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
|
||||||
this.context.addRestorable(this);
|
this.context.addRestorable(this);
|
||||||
this.compile();
|
this.compile();
|
||||||
@ -8143,6 +8145,8 @@ var spine;
|
|||||||
Shader.prototype.getProgram = function () { return this.program; };
|
Shader.prototype.getProgram = function () { return this.program; };
|
||||||
Shader.prototype.getVertexShader = function () { return this.vertexShader; };
|
Shader.prototype.getVertexShader = function () { return this.vertexShader; };
|
||||||
Shader.prototype.getFragmentShader = function () { return this.fragmentShader; };
|
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 () {
|
Shader.prototype.compile = function () {
|
||||||
var gl = this.context.gl;
|
var gl = this.context.gl;
|
||||||
try {
|
try {
|
||||||
@ -8258,7 +8262,7 @@ var spine;
|
|||||||
};
|
};
|
||||||
Shader.newTwoColoredTextured = function (context) {
|
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 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);
|
return new Shader(context, vs, fs);
|
||||||
};
|
};
|
||||||
Shader.newColored = function (context) {
|
Shader.newColored = function (context) {
|
||||||
@ -8893,9 +8897,18 @@ var spine;
|
|||||||
}
|
}
|
||||||
var darkColor = this.tempColor2;
|
var darkColor = this.tempColor2;
|
||||||
if (slot.darkColor == null)
|
if (slot.darkColor == null)
|
||||||
darkColor.set(0, 0, 0, 1);
|
darkColor.set(0, 0, 0, 1.0);
|
||||||
else
|
else {
|
||||||
darkColor.setFromColor(slot.darkColor);
|
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;
|
var slotBlendMode = slot.data.blendMode;
|
||||||
if (slotBlendMode != blendMode) {
|
if (slotBlendMode != blendMode) {
|
||||||
blendMode = slotBlendMode;
|
blendMode = slotBlendMode;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
3076
spine-ts/build/spine-webgl.d.ts
vendored
3076
spine-ts/build/spine-webgl.d.ts
vendored
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
4
spine-ts/build/spine-widget.d.ts
vendored
4
spine-ts/build/spine-widget.d.ts
vendored
@ -1486,7 +1486,9 @@ declare module spine.webgl {
|
|||||||
static SAMPLER: string;
|
static SAMPLER: string;
|
||||||
private context;
|
private context;
|
||||||
private vs;
|
private vs;
|
||||||
|
private vsSource;
|
||||||
private fs;
|
private fs;
|
||||||
|
private fsSource;
|
||||||
private program;
|
private program;
|
||||||
private tmp2x2;
|
private tmp2x2;
|
||||||
private tmp3x3;
|
private tmp3x3;
|
||||||
@ -1494,6 +1496,8 @@ declare module spine.webgl {
|
|||||||
getProgram(): WebGLProgram;
|
getProgram(): WebGLProgram;
|
||||||
getVertexShader(): string;
|
getVertexShader(): string;
|
||||||
getFragmentShader(): string;
|
getFragmentShader(): string;
|
||||||
|
getVertexShaderSource(): string;
|
||||||
|
getFragmentSource(): string;
|
||||||
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, vertexShader: string, fragmentShader: string);
|
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, vertexShader: string, fragmentShader: string);
|
||||||
private compile();
|
private compile();
|
||||||
private compileShader(type, source);
|
private compileShader(type, source);
|
||||||
|
|||||||
@ -7881,6 +7881,8 @@ var spine;
|
|||||||
this.tmp2x2 = new Float32Array(2 * 2);
|
this.tmp2x2 = new Float32Array(2 * 2);
|
||||||
this.tmp3x3 = new Float32Array(3 * 3);
|
this.tmp3x3 = new Float32Array(3 * 3);
|
||||||
this.tmp4x4 = new Float32Array(4 * 4);
|
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 = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
|
||||||
this.context.addRestorable(this);
|
this.context.addRestorable(this);
|
||||||
this.compile();
|
this.compile();
|
||||||
@ -7888,6 +7890,8 @@ var spine;
|
|||||||
Shader.prototype.getProgram = function () { return this.program; };
|
Shader.prototype.getProgram = function () { return this.program; };
|
||||||
Shader.prototype.getVertexShader = function () { return this.vertexShader; };
|
Shader.prototype.getVertexShader = function () { return this.vertexShader; };
|
||||||
Shader.prototype.getFragmentShader = function () { return this.fragmentShader; };
|
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 () {
|
Shader.prototype.compile = function () {
|
||||||
var gl = this.context.gl;
|
var gl = this.context.gl;
|
||||||
try {
|
try {
|
||||||
@ -8003,7 +8007,7 @@ var spine;
|
|||||||
};
|
};
|
||||||
Shader.newTwoColoredTextured = function (context) {
|
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 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);
|
return new Shader(context, vs, fs);
|
||||||
};
|
};
|
||||||
Shader.newColored = function (context) {
|
Shader.newColored = function (context) {
|
||||||
@ -8638,9 +8642,18 @@ var spine;
|
|||||||
}
|
}
|
||||||
var darkColor = this.tempColor2;
|
var darkColor = this.tempColor2;
|
||||||
if (slot.darkColor == null)
|
if (slot.darkColor == null)
|
||||||
darkColor.set(0, 0, 0, 1);
|
darkColor.set(0, 0, 0, 1.0);
|
||||||
else
|
else {
|
||||||
darkColor.setFromColor(slot.darkColor);
|
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;
|
var slotBlendMode = slot.data.blendMode;
|
||||||
if (slotBlendMode != blendMode) {
|
if (slotBlendMode != blendMode) {
|
||||||
blendMode = slotBlendMode;
|
blendMode = slotBlendMode;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -253,9 +253,8 @@ module spine.webgl {
|
|||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
vec4 texColor = texture2D(u_texture, v_texCoords);
|
vec4 texColor = texture2D(u_texture, v_texCoords);
|
||||||
float alpha = texColor.a * v_light.a;
|
gl_FragColor.a = texColor.a * v_light.a;
|
||||||
gl_FragColor.a = alpha;
|
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
||||||
gl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -122,8 +122,18 @@ module spine.webgl {
|
|||||||
finalColor.b *= finalColor.a;
|
finalColor.b *= finalColor.a;
|
||||||
}
|
}
|
||||||
let darkColor = this.tempColor2;
|
let darkColor = this.tempColor2;
|
||||||
if (slot.darkColor == null) darkColor.set(0, 0, 0, 1);
|
if (slot.darkColor == null)
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
let slotBlendMode = slot.data.blendMode;
|
let slotBlendMode = slot.data.blendMode;
|
||||||
if (slotBlendMode != blendMode) {
|
if (slotBlendMode != blendMode) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user