Skip to content

Commit 4ec0be0

Browse files
author
David Gillen
committed
Fixed issues with internal alpha handling
1 parent 5a97a70 commit 4ec0be0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/easeljs/display/StageGL.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ this.createjs = this.createjs||{};
5050
* Render___: actual WebGL draw call
5151
* Buffer: WebGL array data
5252
* Cover: A card that covers the entire viewport
53+
* Dst: The existing drawing surface in the shader
54+
* Src: The new data being provided in the shader
5355
*
5456
* - Notes:
5557
* WebGL treats 0,0 as the bottom left, as such there's a lot of co-ordinate space flipping to make regular canvas
@@ -814,7 +816,7 @@ this.createjs = this.createjs||{};
814816
"{{alternates}}" +
815817
"}" +
816818

817-
"gl_FragColor = vec4(color.rgb, color.a * alphaValue);" +
819+
"gl_FragColor = vec4(color.rgb * alphaValue, color.a * alphaValue);" +
818820
"}"
819821
);
820822

@@ -2539,6 +2541,7 @@ this.createjs = this.createjs||{};
25392541
var useCache = (!ignoreCache && item.cacheCanvas) || false;
25402542

25412543
if (!(item.visible && concatAlpha > 0.0035)) { continue; }
2544+
var itemAlpha = item.alpha;
25422545

25432546
if (useCache === false) {
25442547
if (item._updateState){
@@ -2556,19 +2559,21 @@ this.createjs = this.createjs||{};
25562559
this.batchReason = "cachelessFilterInterupt";
25572560
this._renderBatch(); // <----------------------------------------------------
25582561

2562+
item.alpha = 1;
25592563
var shaderBackup = this._activeShader;
25602564
bounds = bounds || item.getBounds();
25612565
item.bitmapCache.define(item, bounds.x, bounds.y, bounds.width, bounds.height, 1, {useGL:this});
25622566
useCache = item.bitmapCache._cacheCanvas;
25632567

2568+
item.alpha = itemAlpha;
25642569
this._activeShader = shaderBackup;
25652570
gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureOutput._frameBuffer);
25662571
}
25672572
}
25682573
}
25692574

25702575
if (useCache === false && item.children) {
2571-
this._appendToBatch(item, cMtx, item.alpha * concatAlpha);
2576+
this._appendToBatch(item, cMtx, itemAlpha * concatAlpha);
25722577
continue;
25732578
}
25742579

@@ -2710,7 +2715,7 @@ this.createjs = this.createjs||{};
27102715
texI[offV1] = texI[offV1+1] = texI[offV1+2] = texI[offV1+3] = texI[offV1+4] = texI[offV1+5] = texIndex;
27112716

27122717
// apply alpha
2713-
alphas[offV1] = alphas[offV1+1] = alphas[offV1+2] = alphas[offV1+3] = alphas[offV1+4] = alphas[offV1+5] = item.alpha * concatAlpha;
2718+
alphas[offV1] = alphas[offV1+1] = alphas[offV1+2] = alphas[offV1+3] = alphas[offV1+4] = alphas[offV1+5] = itemAlpha * concatAlpha;
27142719

27152720
this._batchVertexCount += StageGL.INDICIES_PER_CARD;
27162721

0 commit comments

Comments
 (0)