-
Notifications
You must be signed in to change notification settings - Fork 223
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
Fixes of Quads and NGons. #138
base: master
Are you sure you want to change the base?
Conversation
Update. I've changed the faceVertexCount to uint32_t as potentially an NGon can have 1000000 indices/points. It can be easily done if a geometry was generated with procedural tools like Houdiny/Blender(GeometryNodes). |
Update: 1 I've moved the indicesIDs array to the Triangulator struct. 2 I've fixed zero area calculation for NGons in the AddMesh() function. |
…le is added to ChartOptions.
Update: I made final changes to the Quads/NGons support. Now all works without any artifacts!
I recorded a video according to this update to show and tell about new changes: Further discussion can be here: #135 Some pictures of a final result after a generation: Some pictures to explain a new computeBoundaryIntersection variable which I've added with the latest commit. |
@jpcy could you please review my pull request. I worked hard to deliver Quads/NGons support. |
I think that |
Hi @castano thank you so much for your feedback. Yeah, I agree that the Actually, I tried XAtlas with I've attached a model where you could test the issue: |
Sorry, forgot to mention that to reproduce the artifacts just run this simple code:
|
@@ -5175,14 +5205,22 @@ struct PlanarCharts | |||
m_regionFirstFace.clear(); | |||
m_nextRegionFace.resize(faceCount); | |||
m_faceToRegionId.resize(faceCount); | |||
const bool hasQuadsOrNGons = m_data.mesh->trianglesToPolygonIDs.size() > 0 ? true : false; | |||
Array<bool> parsedFaces; // For Quads/NGons |
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.
miiiiight be beneficial to use std::vector since it'll use that weirdo pseudo bitfield implementation that will reduce memory by a factor 8. Memory consumption by geometry is revealing to be a problem in some scene cases I'm encountering with 100 millions triangles. Maybe less bandwidth can also improve caching and speed, even if it sounds in contradiction with the bit masking and shifts necessary. In GPU talks we say "ALU is free". probably can apply here.
source/xatlas/xatlas.cpp
Outdated
@@ -7280,7 +7385,8 @@ class Chart | |||
// Computing charts checks for flipped triangles and boundary intersection. Don't need to do that again here if chart is planar. | |||
if (m_type != ChartType::Planar && m_generatorType != segment::ChartGeneratorType::OriginalUv) { | |||
XA_PROFILE_START(parameterizeChartsEvaluateQuality) | |||
m_quality.computeBoundaryIntersection(m_unifiedMesh, boundaryGrid); | |||
if (options.computeBoundaryIntersection) // intersect edges. It can create artifacts (little peeces). |
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.
little pieces ?
Nice that you put so many code captures and the video walkthrough to explain your changes. 👍 |
I tried this on the model you provided and noticed that it produced a self-intersection. This is the kind of error that the boundary intersection code is intended to detect. I think the charts that have an invalid parameterization may fall back to the "piecewise" parameterization method and that may be causing the artifacts that you have detected. A better solution may be to add an option to avoid the piecewise parameterization fallback. An even better solution would be to figure out why the piecewise parameterization method is producing these results and try to improve them. Eliminating the self-intersection tests is not a good solution. I have not reviewed the code changes that add support for n-gons, but at the very least, I think this should be addressed in a separate PR. |
@siliconvoodoo thank you so much for your feedback. As far as I know the point of the library is to use only internal classes/structs without any dependencies. So, What would you suggest to use instead of I'll fix the typo. @castano about your latest post: 1 About the green chart 52: This overlap (on your picture) is exaclty the LSCM unwrapping which doesn't count complex charts. This is an expected behaviour when we have smooth/round shapes like a subdivided monkey. The 2 As far as I get the 3 It seems you tested my model with not default parameters of ChartOption. Please use default ChartOption and set 4 About a separate PR: unfortunately, quads and ngons depend on the |
@castano I checked out the computeBoundaryIntersection() function again. You are right. The function tries to remove intersected faces of a uv map. It works per mesh. But it looks like its pretty complicated... |
@castano I'm looking at the issue further. It seems the problem is not with |
Hi @castano @siliconvoodoo it seems I was able to fix the issue with my latest commit. A problem was in this commented code: |
Here is a video with my creepy explanation: |
source/xatlas/xatlas.cpp
Outdated
if (m_faceInAnyPatch.get(oface)) | ||
continue; |
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.
just this part if @jpcy can give an opinion he'd be the most relevant person for analysis.
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.
@siliconvoodoo yeah, I understand your concern. I've added this check because a triangle/face can be added multiple times to an array. But sure, @jpcy knows better if it makes sense.
xatlas/source/xatlas/xatlas.cpp
Line 6879 in f01768a
m_patch.push_back(face); |
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.
Apologies I've deleted my last comment because there were different checks.
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 merged your changes locally and tested on some of my scenes with no particular adverse of negative behaviors compared to original master. (edit: still need to check again with last commits) |
Thanks a lot. There are no any big changes for triangulated meshes. Have you tried meshes which have quads/ngons? |
And another one test. I made the same amount of quads(duplicated monkeys one time) and the same amount of triangles. Quads: 1.44sec, 62000 quads. It looks pretty cool and means that my work for quads and ngons was done pretty well. |
I've removed "#IF 0" fix and will make it as a separate PR as @castano suggested. The Quads/NGons don't depend on it after removing the |
New pull request is here #141 |
… leave it commented to make an option in future.
…s/NGons and I wasn't be able to fix it. So I commented my fixes in the PiecewiseParam::computeChart() function and set "m_isInvalid" to work only for Triangles. I hope someone will fix the PiecewiseParam::computeChart() function in future.
Hi all, I've made commit here: 2f47d81 Unfortunately, the PiecewiseParam::computeChart() function still makes artifacts for Quads/NGons so I had to switch it off. The code is designed for triangles only and I failed to fix this part. I hope someone will fix the PiecewiseParam::computeChart() function in future. Without the the PiecewiseParam::computeChart() function all still works well. |
…d for flipped faces and zero faces.
Update: I uncommented code for flipped polygons only: |
I was going to ask if it wouldn't be simpler to triangulate first then go through triangle parameterization. But I recalled you're doing a blender plugin so you need to preserve the original geometry as much as possible. |
Hi, I did fixes for Quads and NGons. Now all works as a charm without crashes!
My video explanation of changes:
https://youtu.be/d9MWNfvQLtc
Some key points:
Without these changes XAtlas will be crashing.
Pics:
Generated UVs in Blender with XAtlas: