Comments (3)
If you can send me the mesh or post it here I can investigate further. None of my test models have output vertex counts lower than input.
Chart edges add UV seams to a mesh, so the vertex count should be larger than the input mesh. Index count doesn't change, but indices do - to point to the new vertices. You can't just update input mesh vertices alone. See the example.
from xatlas.
Hi,
I am in deep trouble.
I have a mesh with one UV channel (which is used for diffuse texture/image)
I want to generate a second UV channel for Ambient Occlusion. I am using xatlas for generating this.
After generating atlas, if I update the vertices and indices of the mesh based on the atlas values, the diffuse texture is not shown properly.
I am re-ordering the UVs of the generated channel in the vertices order of the mesh (code below) but ambient image is not shown properly as the order of indices in atlas output is different from the original indices of the mesh.
Unfortunately, we cannot specify indices for each UV channel. What should I do?
Can we ask xatlas to generate atlas with the same indices order and vertices of the original mesh?
Please help me. Thanks in advance.
const xatlas::Mesh &mesh = atlas->meshes[0];
size_t new_vertices_count = mesh.vertexCount;
float atlas_width = (float)atlas->width;
float atlas_height = (float)atlas->height;
std::vector<Vector2> *uvs = new std::vector<Vector2>();
Vector2 empty(0, 0);
uvs->reserve(original_vertices_count);
for (uint32_t v = 0; v < original_vertices_count; v++) {
uvs->push_back(empty);
}
for (uint32_t v = 0; v < new_vertices_count; v++) {
const xatlas::Vertex &vertex = mesh.vertexArray[v];
Vector2 uv(vertex.uv[0] / atlas_width, vertex.uv[1] / atlas_height);
size_t xref = vertex.xref;
uvs->at(xref) = uv;
}
from xatlas.
You need to use the geometry from xatlas::Mesh
and use xatlas::Vertex::xref
to copy any vertex attributes (e.g. position, normal, uv1 channel) from the source mesh, like the example. Index order is preserved, but since new vertices are added on chart seams, some indices will point to new vertices (with xref of the original vertex). You're trying to do things backwards - copying xatlas UVs to the original mesh - which won't work.
from xatlas.
Related Issues (20)
- faceVertexCount pb
- Consider restoring texture repack example?
- Question about checking for zero-area-faces?
- Getting Face Materials from Packed Mesh
- co_await support
- Question: mesh transforms
- webassembly build for in browser usage? HOT 1
- How to use this library for regenerating Diffuse UV maps in Unreal Engine? HOT 3
- Packing UV meshes results are invalid HOT 2
- How can chart in internal::pack::Chart be rotated? HOT 2
- support for quad meshes HOT 2
- compilation error: libgtk3 not found error even though gtk is installed HOT 1
- Some charts are flipped after packing HOT 2
- weights dont do anything
- how to solve embree3.dll HOT 1
- How to recompile the shader? I tried to modify a certain shader, but it was not regenerated. I don't know why
- Why is the generation of chessboard grids processed by GPU instead of CPU, so that only one calculation is needed each time, and the rendered code has more universality
- Why is a simple cube unfolding sometimes unstable HOT 1
- Numerical unstable normals calculation causes segfault crashes
- xatlas regression test fails
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xatlas.