Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/image/pixels.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ p5.prototype._copyHelper = (
dw,
dh
) => {
srcImage.loadPixels();
const s = srcImage.canvas.width / srcImage.width;
// adjust coord system for 3D when renderer
// ie top-left = -width/2, -height/2
Expand Down
2 changes: 1 addition & 1 deletion src/webgl/shaders/filters/opaque.frag
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ uniform sampler2D tex0;

void main() {
vec4 color = texture2D(tex0, vTexCoord);
gl_FragColor = vec4(color.rgb, 1.0);
gl_FragColor = vec4(color.rgb / color.a, 1.0);
}
4 changes: 2 additions & 2 deletions src/webgl/shaders/filters/posterize.frag
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ vec3 quantize(vec3 color, float n) {
void main() {
vec4 color = texture2D(tex0, vTexCoord);

vec3 restrictedColor = quantize(color.rgb, filterParameter);
vec3 restrictedColor = quantize(color.rgb / color.a, filterParameter);

gl_FragColor = vec4(restrictedColor.rgb, color.a);
gl_FragColor = vec4(restrictedColor.rgb * color.a, color.a);
}
4 changes: 2 additions & 2 deletions src/webgl/shaders/filters/threshold.frag
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ float luma(vec3 color) {

void main() {
vec4 color = texture2D(tex0, vTexCoord);
float gray = luma(color.rgb);
float gray = luma(color.rgb / color.a);
// floor() used to match src/image/filters.js
float threshold = floor(filterParameter * 255.0) / 255.0;
float blackOrWhite = step(threshold, gray);
gl_FragColor = vec4(vec3(blackOrWhite), color.a);
gl_FragColor = vec4(vec3(blackOrWhite) * color.a, color.a);
}