GithubHelp home page GithubHelp logo

Comments (4)

inaridarkfox4231 avatar inaridarkfox4231 commented on June 1, 2024

For filters other than INVERT, the results when applied to transparent images seem to be different between 1.7.0 and 1.8.0.
APPLY_FILTER_TO_ALPHA

let img;

function preload(){
  img = loadImage("https://inaridarkfox4231.github.io/assets/season/summer_small.png");
}
function setup(){
  createCanvas(img.width, img.height);
  background(img, 64);
  filter(BLUR, 4);
}

version 1.7.0 BLUR

BLUR_64_170

version 1.8.0 BLUR

BLUR_64_180

from p5.js.

perminder-17 avatar perminder-17 commented on June 1, 2024

I've noticed some unusual and hazy behavior when attempting to render images using filters in a WebGL renderer. I'm not sure if this is a limitation of using fast GPU filters or if it's a bug. @davepagurek , if you could pinpoint where this buggy behavior is occurring, it would be very helpful.

from p5.js.

davepagurek avatar davepagurek commented on June 1, 2024

@perminder-17 my initial guess is that this is also caused by not clearing the canvas in enough places. Similar to how I was suggesting adding a clear() in the non-blur branch of filter, we might need to add a clear() in the blur branch of the if statement here, probably before each pg.rect() call:

pg.shader(this.filterShader);
this.filterShader.setUniform('texelSize', texelSize);
this.filterShader.setUniform('canvasSize', [this.width, this.height]);
this.filterShader.setUniform('radius', Math.max(1, filterParameter));
// horiz pass
this.filterShader.setUniform('direction', [1, 0]);
this.filterShader.setUniform('tex0', tmp);
pg.rect(-this.width/2, -this.height/2, this.width, this.height);
// read back to temp buffer
tmp.image(pg, -this.width/2, -this.height/2);
// vert pass
this.filterShader.setUniform('direction', [0, 1]);
this.filterShader.setUniform('tex0', tmp);
pg.rect(-this.width/2, -this.height/2, this.width, this.height);

Hopefully that fixes it? Otherwise there might be some additional we have to do in the blur shader with how alpha is handled.

from p5.js.

davepagurek avatar davepagurek commented on June 1, 2024

This has now been resolved by #6503, so I'm going to close this branch for organizational purposes. Let me know if there are any other cases not covered that we still need to fix!

from p5.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.