-
Notifications
You must be signed in to change notification settings - Fork 208
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
Vertices are moved to zero #95
Comments
Any invalid geometry (e.g. zero-length edges) can't be atlased. |
I do not see them in the viewer and that was why I was not understanding it proper. Ok, so I shall check the atlas index and place them next to the closest valid vertex. This is a little inconvenient as I cannot assume that the UVs will be perfectly clear as they may be generated with all sort of mapping. I will work this issue around then. |
@AlbertoFrancoDD it looks like you're not taking into account that |
@john-chapman IS there a way to block this? I need the mesh to stay consistent with the cuts that were performed by the artist, I cannot change the input mesh. |
The output mesh is exactly consistent with the input mesh - all other vertex data is unchanged, xatlas just needs to duplicate some vertices so that the generated charts will have unique UVs. I don't think there's any way to avoid this, but it shouldn't be a problem. |
I met the same problem. No idea why xatlas wants to split the left part and the right part into two charts. |
can you guys provide an explicit example in c++ @john-chapman on how to re create a new mesh based on xatlas::Vertex::xref ? |
@PerspectivesLab Here's an outline of the way // Example below assumes that YourMeshClass::operator[] accesses vertex data.
const YourMeshClass& inMesh; // Your source mesh for xatlas to process.
YourMeshClass outMesh; // The new mesh that we'll create below.
// Create/generate xatlas::Atlas*.
xatlas::Atlas* atlas = xatlas::Create();
// Setup chart/pack options, add inMesh data to atlas.
// ...
// Generate charts.
xatlas::Generate(atlas, chartOptions, packOptions);
// Construct outMesh from inMesh data + xatlas generated data.
xatlas::Mesh& atlasMesh = atlas->meshes[0]; // Could be per submesh.
outMesh.setVertexCount(atlasMesh.vertexCount);
for (uint32_t outVertexIndex = 0; outVertexIndex < atlasMesh.vertexCount; outVertexIndex++)
{
xatlas::Vertex& vertex = atlasMesh.vertexArray[outVertexIndex];
uint32_t inVertexIndex = vertex.xref; // Index of input vertex from which this output vertex originated.
outMesh[outVertexIndex] = inMesh[inVertexIndex]; // Copy data from the input mesh to the output mesh.
outMesh[outVertexIndex].lightmapUV = { vertex.uv[0] / atlas->width, vertex.uv[1] / atlas->height };
}
outMesh.setIndexData(atlasMesh.indexCount, atlasMesh.indexArray); |
@john-chapman thank you, your help is highly appreciated ! |
Hi,
I am integrating xatlas into a project we are doing for one of our customers. I have found a weird behaviour and I am not sure if it is a bug or a problem with my input. The result is that some vertices in the meshes that I pass to xatlas are collapsed to zero, see image below:
What I am doing is quite simple, the code is as follows:
This is happening with several meshes not just the one displayed on the image, I checked the example and it seems to me that I am doing everything right, Any idea?
The text was updated successfully, but these errors were encountered: