Sub topic 1
What UV Coordinates Are and Why Meshes Need Them
Prerequisites
This chapter assumes you can already do the following in Blender:
- Navigate the 3D viewport (orbit, pan, zoom).
- Switch between Object Mode and Edit Mode.
- Select vertices, edges and faces.
- Recognize a material in the Properties editor, even if you have not built one.
You do not need to know how to unwrap yet. This chapter builds the model that the later chapters rely on: seams, unwrapping, packing and color space all follow from the ideas here.
The problem: a 3D surface and a flat image
A mesh is a set of vertices, edges and faces in three-dimensional space. An image is a flat grid of pixels. To paint a brick wall onto a cube, Blender must answer one question for every point on the surface: which pixel of the image belongs here?
Position in 3D space cannot answer it. The image has no depth, and the mesh can be rotated, scaled or deformed by an animation. The answer has to be a mapping that is stored with the mesh and travels with it. That mapping is the UV map.
What U and V mean
U and V are the names of the two axes of a 2D coordinate system. The letters differ from X, Y and Z so that they are never confused with positions in 3D space.
- U is the horizontal axis of the image.
- V is the vertical axis of the image.
Both run from 0 to 1 across the image, regardless of its pixel size. A point at (0, 0) is the bottom-left corner. A point at (1, 1) is the top-right corner. A point at (0.5, 0.5) is the center. Because the range is normalized, the same UV map works for a 512 by 512 image and for a 4096 by 4096 image. Only the sharpness changes.
The region from 0 to 1 in both axes is called UV space (or texture space). In the UV Editor it is drawn as a square with the image behind it.
UVs belong to face corners, not vertices
A common assumption is that each vertex stores one UV coordinate. That is not how Blender stores them. Each face corner stores one. A face corner, also called a loop, is the place where one face meets one vertex.
The difference matters. Take a vertex shared by four faces. It has one position in 3D space, but it has four face corners, one per face. Each of those corners can hold a different UV pair. This is what allows a mesh to be cut open: the shared vertex can sit at one spot in the image for one face and at a distant spot for its neighbor. Section "Seams" in a later chapter relies on this.
The following script shows the storage directly. It prints the UV pair for the first six face corners of the active object.
import bpy
obj = bpy.context.active_object
uv_layer = obj.data.uv_layers.active
# Print the UV coordinate of the first few face corners (loops).
for i, loop_uv in enumerate(uv_layer.data[:6]):
print(i, tuple(loop_uv.uv))Run it with a mesh selected, for example the default cube, and look at the output in the system console or the Scripting workspace. A default cube has 6 faces with 4 corners each, so the layer holds 24 entries even though the cube has only 8 vertices. The number of entries equals the number of face corners, not the number of vertices.
If the active object has no UV map, uv_layers.active is None and the script raises an AttributeError. Meshes created through the Add menu get a UV map automatically. Meshes built from scratch with scripts or imported from some formats may not.
UV maps as named layers
A mesh can hold several UV maps, each in its own layer with a name. The default is usually UVMap. You manage them in the Properties editor under Object Data, in the UV Maps panel.
Several maps are useful in practice:
- One map for tiling surface detail, such as a repeating fabric weave.
- One non-overlapping map for baked lighting, where every face needs its own unique space.
Exactly one map is active for editing, which is the one shown in the UV Editor. A different setting, the active render map (the camera icon beside each layer), decides which map is used by default when rendering. A material can also choose a map by name using a UV Map node, which becomes relevant when you use more than one.
Why an unwrapped layout is needed
Consider a cube. It can be cut along its edges and laid flat as a cross shape, like a cardboard box before assembly. The faces keep their shapes and the image covers the flat layout without distortion.
A sphere is different. No flat sheet can cover a sphere without cutting, stretching or both. Cartographers face the same problem with world maps. Every map projection distorts something: area, angle or distance. The same holds for mesh surfaces. Unwrapping is the process of cutting a surface open and flattening it so that the distortion stays small and sits where nobody looks.
This explains the structure of the whole workflow:
- Seams decide where the mesh is cut.
- Unwrapping flattens the cut mesh into islands.
- Checks reveal how much distortion remains.
- Scale and packing decide how much image space each island gets.
An island is a connected group of faces in UV space. Two faces that share an edge and also share the same UV positions along that edge stay joined in one island. Where the UV positions differ along a shared edge, the island is split there.
Reading a UV layout
When you open a UV map in the UV Editor, each mesh face appears as a polygon. Three properties of that picture tell you most of what you need to know:
| What you see | What it means |
|---|---|
| Polygon has the same shape as its 3D face | Little distortion in that area |
| Polygon is much larger than neighbors | That face gets more image pixels and looks sharper |
| Polygons overlap each other | Different faces sample the same pixels and share the same picture |
| Polygons extend outside the 0 to 1 square | The image repeats or stretches there, depending on extension settings |
Overlap is not always a mistake. Mirrored halves of a character often share space deliberately to save resolution. It becomes a problem when the image holds unique information for each face, such as baked shadows or hand-painted detail.
Where the UV map meets the material
A UV map does nothing alone. It becomes visible when a texture node reads it. The Image Texture node takes a vector input, and when nothing is connected to that input, it uses the active UV map by default. The node samples the image at each UV position and outputs a color. That color can feed the Base Color input of the Principled BSDF.
The next chapter covers the node in detail. A short script gives a preview of the whole chain: mesh, UV map, image node, material.
import bpy
obj = bpy.context.active_object
mat = bpy.data.materials.new("TexturedMaterial")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
bsdf = nodes["Principled BSDF"]
tex = nodes.new("ShaderNodeTexImage")
tex.image = bpy.data.images.load("//textures/brick_color.png")
tex.image.colorspace_settings.name = "sRGB"
links.new(tex.outputs["Color"], bsdf.inputs["Base Color"])
obj.data.materials.append(mat)The path //textures/brick_color.png is relative to the saved .blend file, so the file must be saved first and the image must exist at that location. If it does not, bpy.data.images.load raises an error.
A way to see UVs: the test grid
You can make a UV problem visible by replacing the real image with a generated grid. Each square of the grid should look square on the surface. Squares that stretch into rectangles, or that vary in size from face to face, show distortion and uneven resolution.
import bpy
img = bpy.data.images.new("UVTestGrid", width=1024, height=1024)
img.generated_type = 'UV_GRID'Assign this image in an Image Texture node, then switch the viewport to Material Preview. A later chapter covers how to read the result. For now it is enough to know that the grid makes an invisible mapping visible.
Common errors and misconceptions
- "UVs are positions on the mesh." They are not. Vertex positions and UV coordinates are stored separately. Moving a vertex in 3D leaves its UV unchanged, and moving a UV leaves the 3D shape unchanged.
- "The image looks fine, so the UVs are fine." A flat color or noise texture hides stretching. Check with a grid.
- "A cube needs no unwrapping." Meshes made with the Add menu include a default unwrap, but it is generic and often wastes space or overlaps faces. Primitives other than the cube may also give poor results for your texture.
- Texture appears black or pink. In the viewport, pink usually means the image is missing. A black result often means the image node has no image assigned, or the mesh has no UV map for the node to read.
- Edits to the mesh change the UVs unexpectedly. Adding geometry such as extrusions, loop cuts and subdivisions creates new face corners. Blender interpolates UVs for those corners, which may be wrong. Re-check the layout after structural edits.
How the concepts connect
UV coordinates are the base of the whole chapter sequence. The Image Texture node reads them. The UV Editor shows and edits them. Seams determine where islands are cut. Unwrapping computes the positions. Checks and packing then refine how well those positions use the image. Each later step exists because a flat image cannot cover a curved mesh without decisions about cuts, scale and layout.
Exercise
A default cube has 8 vertices, 12 edges and 6 faces. How many entries does its UV layer hold, and why is that number different from the vertex count? What does this difference allow Blender to do at a shared vertex?
Show answer
The UV layer holds 24 entries, one for each face corner (6 faces times 4 corners). A vertex shared by three faces on a cube has three corners, each with its own UV pair. This lets the same 3D vertex appear at different places in the image for different faces, which is how a mesh is cut open into islands.
Exercise
A UV polygon for one face is twice as wide and twice as tall as the polygons for the faces around it, and the image is a unique painted texture. What will you see on the surface, and is it always a mistake?
Show answer
That face samples four times as much image area, so it shows more pixel detail and looks sharper than its neighbors, and the texture scale looks inconsistent across the surface. It is not always a mistake. You may want extra resolution on an important area such as a face or a label. It is a problem when it happens by accident, which a test grid reveals as squares of different sizes.