File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -717,7 +717,17 @@ this.createjs = this.createjs||{};
717717 "{{alternates}}" +
718718 "}" +
719719
720- "gl_FragColor = vec4(color.rgb{{premultiply}}, color.a * alphaValue);" +
720+ "{{fragColor}}" +
721+ "}"
722+ ) ;
723+ StageGL . REGULAR_FRAG_COLOR_NORMAL = (
724+ "gl_FragColor = vec4(color.rgb, color.a * alphaValue);"
725+ ) ;
726+ StageGL . REGULAR_FRAG_COLOR_PREMULTIPLY = (
727+ "if(color.a > 0.0035) {" + // 1/255 = 0.0039, so ignore any value below 1 because it's probably noise
728+ "gl_FragColor = vec4(color.rgb/color.a, color.a * alphaValue);" +
729+ "} else {" +
730+ "gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);" +
721731 "}"
722732 ) ;
723733
@@ -1605,7 +1615,7 @@ this.createjs = this.createjs||{};
16051615 insert += "} else if (indexPicker <= " + i + ".5) { color = texture2D(uSampler[" + i + "], vTextureCoord);" ;
16061616 }
16071617 str = str . replace ( / { { alternates} } / g, insert ) ;
1608- str = str . replace ( / { { premultiply } } / g, this . _premultiply ? "/color.a" : "" ) ;
1618+ str = str . replace ( / { { fragColor } } / g, this . _premultiply ? StageGL . REGULAR_FRAG_COLOR_NORMAL : StageGL . REGULAR_FRAG_COLOR_PREMULTIPLY ) ;
16091619
16101620 // actually compile the shader
16111621 var shader = gl . createShader ( type ) ;
You can’t perform that action at this time.
0 commit comments