Giter VIP home page Giter VIP logo

Comments (3)

jpcy avatar jpcy commented on June 18, 2024

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.

oschakravarthi avatar oschakravarthi commented on June 18, 2024

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.

jpcy avatar jpcy commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.