-
-
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
Adding framebuffer support for filter() + CreateFilterShader for 2D mode #6559
Merged
Merged
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
198e456
Adding framebuffer support in filter
perminder-17 8b71469
Update p5.RendererGL.js
perminder-17 0ec719e
Update material.js
perminder-17 96bc262
Update p5.RendererGL.js
perminder-17 72cd97b
Reset matrix.js
perminder-17 6f0b715
Added test for filterCamera.js
perminder-17 2789e2a
Checking if pixelDensity is defined.js
perminder-17 2df0b03
Update p5.RendererGL.js
perminder-17 f42da57
Update material.js
perminder-17 cefc285
Update p5.RendererGL.js
perminder-17 9a86b19
merging
perminder-17 75b0042
Delete lib/empty-example/sketch.js
perminder-17 ae37304
function matchsize().js
perminder-17 e807740
fixed typo.js
perminder-17 1af2155
some fixes
perminder-17 7fa39f6
Update p5.RendererGL.js
perminder-17 683ed18
restore.js
perminder-17 c250531
Update p5.RendererGL.js
perminder-17 e4291cd
resizeCanvas to resize.js
perminder-17 b073664
fixes.js
perminder-17 a353711
fixes.js
perminder-17 4a9bef9
lint fix.js
perminder-17 2a330bf
Rename tests.js
perminder-17 6d04ec6
fixes.js
perminder-17 b1ec441
add test.js
perminder-17 c01235f
fixes.js
perminder-17 8df7437
fixes.js
perminder-17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a case where these conditions weren't met?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, during testing, there seems to be an issue where, after a resize operation, logging
console.log(this._pInst)
sometimes results in the valueundefined
. This occurrence leads to errors of the form "cannot read properties of undefined (reading_pixelDensity
)". To address this, a check has been added to verify whetherthis._pInst
is defined before attempting to access its properties. This check helps prevent the errors encountered during the testing process. It was actually failing the test given below. Am I doing the correct way....Or this still have limitations?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for pointing out the test case! I was asking because it seems like it might be indicative of a bigger problem if something is getting resized without having a
_pInst
, and maybe we want to see how it got into that state and maybe fix it at the source instead of here. I'll take a look at that test and get back to you soon!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's coming from these lines:
p5.js/src/webgl/p5.RendererGL.js
Lines 1432 to 1435 in 28740f9
These were added when
filterGraphicsLayer
was a graphic, but now it's a framebuffer. I think we don't need those lines at all any more since we handle the resizing when we callfilter
, so maybe we can take it out, and check instead that the size changes after callingfilter
:test('secondary graphics layer matches main canvas size', function() { let g1 = myp5.createCanvas(5, 5, myp5.WEBGL); let s = myp5.createShader(vert, frag); myp5.filter(s); let g2 = g1.filterGraphicsLayer; assert.deepEqual([g1.width, g1.height], [g2.width, g2.height]); myp5.resizeCanvas(4, 4); + myp5.filter(s); assert.deepEqual([g1.width, g1.height], [g2.width, g2.height]); });
Also as a side note, we should still rename
filterGraphicsLayer
andfilterGraphicsLayerTemp
inRendererGL
to remove the wordgraphic
(justfilterLayer
andfilterLayerTemp
probably)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, i have done a little testing myself, I think it's working now. I have made the required changes.