Skip to content

Commit cd713ce

Browse files
author
David Gillen
committed
Resolve discrepancies in alpha handling between GL filters and regular filters and minor bugs
1 parent e913f2c commit cd713ce

4 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/easeljs/filters/AberrationFilter.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,12 @@
161161
var grnPixel = ((grnY*width)+grnX)*4;
162162
var bluPixel = ((bluY*width)+bluX)*4;
163163

164-
if(this._alphaMax) {
165-
outPixels[pixel] = refPixels[redPixel];
166-
outPixels[pixel+1] = refPixels[grnPixel+1];
167-
outPixels[pixel+2] = refPixels[bluPixel+2];
168-
outPixels[pixel+3] = refPixels[pixel+3];
169-
} else {
170-
outPixels[pixel] = refPixels[redPixel];
171-
outPixels[pixel+1] = refPixels[grnPixel+1];
172-
outPixels[pixel+2] = refPixels[bluPixel+2];
173-
outPixels[pixel+3] = refPixels[pixel+3];
174-
}
164+
outPixels[pixel] = refPixels[redPixel];
165+
outPixels[pixel+1] = refPixels[grnPixel+1];
166+
outPixels[pixel+2] = refPixels[bluPixel+2];
167+
outPixels[pixel+3] = this._alphaMax ?
168+
Math.max(refPixels[redPixel+3], refPixels[grnPixel+3], refPixels[bluPixel+3]) :
169+
(refPixels[redPixel+3] + refPixels[grnPixel+3] + refPixels[bluPixel+3]) / 3;
175170
}
176171
}
177172

src/easeljs/filters/AlphaMapFilter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ this.createjs = this.createjs || {};
108108

109109
// some image formats can have transparent white rgba(1,1,1, 0) when put on the GPU, this means we need a slight tweak
110110
// using ceil ensure that the colour will be used so long as it exists but pure transparency will be treated black
111-
"gl_FragColor = vec4(color.rgb, color.a * (alphaMap.r * ceil(alphaMap.a)));" +
111+
"float newAlpha = alphaMap.r * ceil(alphaMap.a);" +
112+
"gl_FragColor = vec4(clamp(color.rgb/color.a, 0.0, 1.0) * newAlpha, newAlpha);" +
112113
"}"
113114
);
114115

src/easeljs/filters/AlphaMaskFilter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ this.createjs = this.createjs || {};
9191
"vec4 color = texture2D(uSampler, vTextureCoord);" +
9292
"vec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);" +
9393

94-
"gl_FragColor = vec4(color.rgb, color.a * alphaMap.a);" +
94+
"gl_FragColor = vec4(color.rgb * alphaMap.a, color.a * alphaMap.a);" +
9595
"}"
9696
);
9797
}

src/easeljs/filters/DisplacementFilter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ this.createjs = this.createjs||{};
116116
var canvas = this._dudvCanvas = createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
117117
canvas.width = dudvMap.width;
118118
canvas.height = dudvMap.height;
119-
(this._dudvCtx = canvas.getContext("2d")).drawImage(dudvMap);
119+
(this._dudvCtx = canvas.getContext("2d")).drawImage(dudvMap, 0,0);
120120
}
121121
}
122122
var p = createjs.extend(DisplacementFilter, createjs.Filter);

0 commit comments

Comments
 (0)