-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas becomes strange when using translate() and filter function in 2D mode #6502
Comments
In addition, the behavior when drawing with lower opacity seems to be different from that in 1.7.0. snipetlet 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(~~~);
} version 1.7.0version 1.8.0However, if "this" is the future behavior of 2D filter(), this is not considered a bug, so there is no problem. |
It looks like all of the bug behaviour happens here: p5.js/src/webgl/p5.RendererGL.js Lines 1129 to 1133 in 611941a
|
Hey @davepagurek , I am interested in working on this issue. Could you please add some more context to what you are trying to say through this:
ThankYou! |
Thankyou for your suggestion @davepagurek |
For reference, here is an example: function setup() {
createCanvas(400, 400);
let gr=createGraphics(100,100);
gr.textAlign(CENTER,CENTER);
gr.textSize(80);
gr.text("🦊",50,50);
gr.filter(INVERT);
background(128);
image(gr,100,100);
} version 1.7.0version 1.8.0 |
Finally, this is not a bug report, just a chat, but there seems to be a slight difference in the behavior of BLUR when the background is transparent in 2D and webgl. function setup(){
createCanvas(400, 400);
clear();
textAlign(CENTER, CENTER);
textSize(180);
text("🐬",200,200);
filter(BLUR, 10, true/false);
} use webglFilternot use webglFilterThese are the points that I was concerned about about the filter function that was implemented this time. I'll leave it to you to decide what to do with these. In the p5.js community to which I belong, even the first thing I raised is not considered a bug. So I can't determine whether these are bugs or not. So I'll leave everything to you regarding to handle these. |
Hey @inaridarkfox4231 thanks for your reports. I'd suggest filing separate issues for each unexpected behavior you noticed as they most likely have different causes. This will make it easier to track the issues and possible solutions. |
I got it. Let's separate the transform issue and transparency issue. |
Regarding "blur", I think this is a subjective issue as it is a question of how to define "blur". I can't decide whether or not it should be treated as a bug, so I'll leave everything up to the person who created the specifications. |
Because they look so different. This is no longer a question of what is the correct way to define BLUR, but how to define a new BLUR. function setup() {
createCanvas(400, 400);
let gr=createGraphics(400,400,WEBGL);
gr.clear();
gr.noStroke();
gr.fill("red");
gr.lights();
gr.push();
gr.rotateX(0.5);
gr.rotateY(0.6);
gr.rotateZ(0.2);
gr.box(100);
gr.pop();
image(gr,0,0);
filter(BLUR, 20, true/false);
} version 1.7.0 BLURversion 1.8.0 BLUR |
I think the blur issue is the same as the transparency one, as it only happens when the background is not fully opaque (adding |
I agree. It seems like the issue is how to handle transparency. It may be necessary to modify the shader. |
For dealing with the transformation of the canvas, I think we need to make sure we call It would be great if we could add some unit tests so we can make sure it works in a few scenarios, and stays working for future changes. Maybe we could have some tests that:
For the transformations to test, we could have a test case for:
|
Also, it doesn't seem to support p5.Framebuffer (it might not be possible in the first place...) let fb;
function setup() {
createCanvas(400, 400, WEBGL);
fb = createFramebuffer({w:width, h:height});
}
function draw(){
fb.begin();
orbitControl();
background(0);
lights();
fill(255,0,0);
specularMaterial(128);
noStroke();
torus(80, 20, 48);
//filter(INVERT);
fb.end();
clear();
image(fb.color, -200, -200);
filter(INVERT);
} 2023-10-31.22-58-56.mp4Maybe I'm applying it wrong, or maybe I shouldn't use it this way. |
I think the framebuffer one is solvable but would mean not applying filters on a separate graphic, and instead using another framebuffer in the same WebGL context. That's something we probably want to look into anyway for filters on WebGL canvases as it'll be faster than using a graphic. Feel free to open an issue for that too if you're interested! Otherwise I'll also get around to filing one at some point. |
I understood. I'm not familiar with p5.Framebuffer, so I'll leave this up to you. |
I checked several pull requests related to the development of the filter() specification. I got the impression that the situation to which it would be applied was fixed, and it was just a matter of matching the appearance. However, since image() is a function that draws the board, the effects of transform and blend cannot be avoided. I think that should have been considered. |
Most appropriate sub-area of p5.js?
p5.js version
1.8.0
Web browser and version
Chrome
Operating System
Windows11
Steps to reproduce this
Steps:
Snippet:
2D_BLUR_BUG
version 1.7.0
version 1.8.0
The text was updated successfully, but these errors were encountered: