[libgdx] Ported new tint black shader. See #1003. @nathansweet please have a look.

This commit is contained in:
badlogic 2017-09-30 09:27:08 +02:00
parent 221372e409
commit 2c45dd2f1e
2 changed files with 5 additions and 4 deletions

View File

@ -240,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;
@ -293,9 +294,9 @@ public class SkeletonRenderer {
| (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 * multiplier) << 16) //
| ((int)(g * darkColor.g * color.g * multiplier) << 8) //
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();

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);