-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(webgl): normalize nearly identical vertices before tessellation #8221
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
Open
avinxshKD
wants to merge
5
commits into
processing:dev-2.0
Choose a base branch
from
avinxshKD:fix/tessellation-nearly-identical-vertices-dev-2.0
base: dev-2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5155fbc
fix(webgl): normalize nearly identical vertices before tessellation
avinxshKD e76c040
Merge branch 'dev-2.0' into fix/tessellation-nearly-identical-vertice…
perminder-17 291f70f
fix(webgl): normalize nearly identical vertices before tessellation
avinxshKD 0be03d3
Merge branch 'dev-2.0' into fix/tessellation-nearly-identical-vertice…
perminder-17 bd7011f
Fixing merge conflicts.
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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -692,6 +692,37 @@ visualSuite('WebGL', function() { | |
| }); | ||
| }); | ||
|
|
||
| visualSuite('Tessellation', function() { | ||
| visualTest('Handles nearly identical consecutive vertices from textToContours', async function(p5, screenshot) { | ||
| p5.createCanvas(200, 200, p5.WEBGL); | ||
| p5.background(255); | ||
| p5.fill(0); | ||
| p5.noStroke(); | ||
|
|
||
| const font = await p5.loadFont('/unit/assets/Inconsolata-Bold.ttf'); | ||
| const contours = font.textToContours('p', 0, 0, 60); | ||
|
|
||
| if (contours && contours.length > 0) { | ||
| p5.translate(-p5.width / 4, -p5.height / 4); | ||
| p5.beginShape(); | ||
| for (let contourIdx = 0; contourIdx < contours.length; contourIdx++) { | ||
| const contour = contours[contourIdx]; | ||
| if (contourIdx > 0) { | ||
| p5.beginContour(); | ||
| } | ||
| for (let i = 0; i < contour.length; i++) { | ||
| p5.vertex(contour[i].x, contour[i].y, 0); | ||
|
Comment on lines
+697
to
+714
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is still not reproducing the issue for which you're adding the visual tests. Please use this sketch for the tests: function setup() {
createCanvas(400, 400, WEBGL);
}
function draw() {
const contours = [
[
[-3.8642425537109375,-6.120738636363637,0],
[3.2025188099254267,-6.120738636363637,0],
[3.2025188099254267,-4.345170454545455,0],
[-3.8642425537109375,-4.345170454545455,0],
[-3.8642425537109375,-6.120738636363637,0],
],
[
[-1.8045834628018462,4.177556818181818,0],
[-1.8045834628018462,-9.387784090909093,0],
[0.29058699174360836,-9.387784090909093,0],
[[0.2905869917436083,3.609374411367136,0]] // doesnt work
[0.31044303036623855,4.068235883781435,0],
[0.38522861430307975,4.522728865422799,0],
[0.548044378107245,4.941051136363637,0],
[0.8364672032828204,5.2932224887960775,0],
[1.2227602871981542,5.526988636363637,0],
[1.6572258237923885,5.634502949876295,0],
[2.101666537198154,5.669034090909091,0],
[2.6695604948237173,5.633568761673102,0],
[3.0249619917436084,5.5625,0],
[3.4510983553799726,7.4446022727272725,0],
[2.8568950819856695,7.613138889205699,0],
[2.3751340936529037,7.676962586830456,0],
[1.8892600236717598,7.693181792704519,0],
[1.2922705720786674,7.649533731133848,0],
[0.7080836288276859,7.519788939617751,0],
[0.14854153719815422,7.311434659090909,0],
[-0.38643934048179873,7.00959666478984,0],
[-0.858113258144025,6.61653855366859,0],
[-1.25415732643821,6.1484375,0],
[-1.5108595282965422,5.697682732328092,0],
[-1.6824918355513252,5.207533878495854,0],
[-1.7762971052870198,4.695933154267308,0],
[-1.8045834628018462,4.177556818181818,0],
]
]
background('red')
push()
stroke(0)
fill('#EEE')
scale(15)
beginShape()
for (const contour of contours) {
beginContour()
for (const v of contour) {
vertex(...v)
}
endContour()
}
endShape()
stroke(0, 255, 0)
strokeWeight(5)
beginShape(POINTS)
for (const contour of contours) {
for (const v of contour) {
vertex(...v)
}
}
endShape()
pop()
} |
||
| } | ||
| if (contourIdx > 0) { | ||
| p5.endContour(); | ||
| } | ||
| } | ||
| p5.endShape(p5.CLOSE); | ||
| } | ||
| screenshot(); | ||
| }); | ||
| }); | ||
|
|
||
| visualSuite('textures in p5.strands', async () => { | ||
| visualTest('uniformTexture() works', async (p5, screenshot) => { | ||
| p5.createCanvas(50, 50, p5.WEBGL); | ||
|
|
||
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.
The new visual test doesn’t actually cover this change. I see the same output before and after the patch. Please update the sketch to reproduce the bug which is fixed at your PR.
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.
Worst case we can just use the exact same tests as in the original issue. I don't fully understand either why this case seems OK but not the one in the issue haha. I wonder if my numbers were bigger in the original and that causes more numerical precision issues
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.
Hello @perminder-17 @davepagurek thanks for the review
As you said that Visual test not showing the bug
Should I use the exact
textToContours()example from issue [p5.js 2.0 Bug Report]: Tessellation of beginShape/endShape with multiple contours sometimes produces weird results #8186?That one clearly shows the glitchy tessellation before the fix. I can add that as the visual test.
Also about Z coordinates
I included Z because I thought it would be safer to normalize all three axes consistently. But you're right that the original issue only mentions X/Y coordinates. Should I:
Let me know and I'll update the PR accordingly and will also add similar changes to #8204
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.
For this one, maybe yes. you could add that in this scenario.
for this one, I tested it and I don't think we need to snap z coordinates.