2
$\begingroup$

When working with Graphics APIs like OpenGL its common to use an index face set model. That is, multiple faces share adjacent / overlapping vertices by using a list of indices.

Most game engines like Unity come with an integrated lightmapper that provides automatic UV unwrapping (UVs for lightmaps are usually different from those for the albedo texture).

However, automatic UV unwrapping (or UV unwrapping in general) means almost certainly seams which means a single vertex (along the seam) must have multiple UV coordinates (one for each face) if the faces are laid out in different charts in the UV atlas.

How is this dealt with in like Blender or Unity? Does the process of UV unwrapping add more vertices and modify the model? At least I'm not aware that UV unwrapping in Unity for lightmap generation changes my model.

$\endgroup$

1 Answer 1

1
$\begingroup$

Does the process of UV unwrapping add more vertices and modify the model?

Yes, in general. The final model that is rendered, i.e. what the GPU sees, will have vertices with the same position but differing UV values. The triangles on one side of the seam will reference one set of vertices, and on the other side of the seam reference different vertices.

The same thing happens when "hard edges" are added to the model: you have vertices with the same position but differing normals. In fact this can happen with any vertex attribute, but UVs and normals are the most common cases.

The way that models are represented in an editing tool like Blender can be different, though. To facilitate editing operations, they will have data structures that are able to keep track of the fact that it's conceptually one vertex even if it has multiple UV or normal values. For example, they might store separate lists of positions, UVs, and normals, and let each face have separate indices for the position, UV, and normal of each face-vertex. That way, any modeling operations that move the vertex position will keep all the faces welded together properly, since they are all indexing the same element of the positions array. (I don't know if this is actually how Blender does it; it's just an example.)

The engine's lightmapping pipeline might also use such a representation internally for constructing the UV unwrap. But ultimately, before rendering, the engine's asset pipeline will convert the model into the GPU-ready format with multiple vertices and one index per face-vertex (as well as doing various other cleanup/optimization on the model).

$\endgroup$
1
  • 1
    $\begingroup$ After some digging into Unity and Godot source code I was able to conclude that at least in case of lightmapping, the UV unwrapping (if enabled) happens probably during model import and the modified / processed model is then stored in some internal format. In case of Unity, this seems to be inside the ArtifactDB. $\endgroup$
    – Sam
    Dec 12, 2021 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.