Sub topic 7
Keeping Texture Resolution Consistent Across Islands
This chapter assumes you can unwrap a mesh with seams, open the UV Editor, and connect an Image Texture node to a Principled BSDF. It also assumes you have read the chapter on checking distortion with a test grid. The chapter covers what texel density is, how to see uneven density, how to correct it, and when to leave it uneven on purpose.
What texel density is
A texel is one pixel of a texture, counted as it lands on a surface. Texel density is the number of texels that cover one unit of surface, usually written as pixels per meter (px/m).
A mesh has two sizes at once. Each face has a real size in 3D space, and each face also has a size in UV space, which is a fraction of the image. Texel density is the link between them:
texel density (px/m) = island length in UV (0 to 1) x image length in px / surface length in metersHere is a worked example with a 1024 px image. A wall is 2 m wide. Its island spans 0.5 of the U axis, which is 512 px, so the density is 512 / 2 = 256 px/m. A crate next to it is 0.5 m wide. Its island also spans 0.5 of the U axis, which is 512 px, so the density is 512 / 0.5 = 1024 px/m.
Both islands use the same amount of image, but the crate gets four times the detail. A brick pattern painted on both would show bricks of different sizes, and the crate's texture would look sharp while the wall's looks blurry. Both faults come from island scale, not from any unwrap method.
Why it matters
Uneven density causes problems you can see:
- Patterns such as bricks, planks, or text change size between neighboring objects or parts of one object.
- Some parts look blurry while others look crisp, even though they share one image.
- Texture memory is wasted on small or hidden faces that received a large island.
- Seams between islands at different densities are easier to notice, because the texture changes scale across the cut.
The unwrap algorithms do not fix this for you. Each island is flattened on its own. Its size relative to other islands depends on the method and on how the result was fitted into the 0 to 1 square, so you have to check and correct it.
Seeing uneven density
You have three ways to look at density. Use them together.
The test grid
Assign a generated UV grid or checker image to the material. If the squares are the same size on every part of the mesh, density is consistent. If squares on one part are larger, that part has lower density.
import bpy
img = bpy.data.images.new("UVTestGrid", width=1024, height=1024)
img.generated_type = 'UV_GRID'Plug this image into an Image Texture node on the material and view the object in Material Preview or Rendered shading. Compare squares across the whole object, including the back and underside.
The stretch overlay
In the UV Editor, open the Overlays popover and enable Stretching. Choose Angle or Area. The Area mode colors each face by how much its UV area differs from its 3D area. Blue means little change, and green, yellow, and red mean more. The overlay mainly shows distortion inside an island. It compares each face to a reference, so it can also flag an island that is badly scaled against the rest, but the test grid is the clearer check for that.
A measurement script
The grid is visual, so numbers help when you need to compare precisely. This script reports the texel density of every face of the active object, in pixels per meter, and prints the lowest, highest, and mean.
import bpy
from math import sqrt
from mathutils import geometry
IMAGE_SIZE = 1024 # pixels along one side of a square texture
obj = bpy.context.active_object
if obj.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT') # Edit Mode data is not yet written to the mesh
mesh = obj.data
uv_data = mesh.uv_layers.active.data
world = obj.matrix_world
def uv_area(uvs):
# Shoelace formula for a polygon in UV space.
total = 0.0
for i in range(len(uvs)):
x1, y1 = uvs[i]
x2, y2 = uvs[(i + 1) % len(uvs)]
total += x1 * y2 - x2 * y1
return abs(total) / 2.0
def world_area(points):
# Triangle fan from the first point.
return sum(
geometry.area_tri(points[0], points[i], points[i + 1])
for i in range(1, len(points) - 1)
)
densities = []
for poly in mesh.polygons:
points = [world @ mesh.vertices[mesh.loops[i].vertex_index].co
for i in poly.loop_indices]
uvs = [tuple(uv_data[i].uv) for i in poly.loop_indices]
a3d = world_area(points)
auv = uv_area(uvs)
if a3d > 0 and auv > 0:
densities.append(sqrt(auv) * IMAGE_SIZE / sqrt(a3d))
if densities:
print("faces measured:", len(densities))
print("min px/m: %.1f" % min(densities))
print("max px/m: %.1f" % max(densities))
print("mean px/m: %.1f" % (sum(densities) / len(densities)))
print("max/min ratio: %.2f" % (max(densities) / min(densities)))The script takes the square root of the area ratio, because density is a length measure and area is a length squared. It uses world-space positions, so object scale is included. A max/min ratio close to 1.0 means consistent density. A ratio of 4 or more means some faces get four times the detail of others.
Because it measures per face, it also shows distortion within an island. A large ratio does not always mean islands are scaled differently. Stretching inside an island raises the ratio too, so compare the result with the test grid.
Correcting island scale
Blender has an operator for the main fix. In the UV Editor, select the islands you want to adjust, then choose UV > Average Islands Scale. It rescales each selected island so that its UV area is proportional to its area in 3D space. Islands that were too small grow, and islands that were too large shrink. After that, the squares of a test grid should match in size.
import bpy
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.uv.select_all(action='SELECT') # in UV Sync Selection off, select UVs too
bpy.ops.uv.average_islands_scale()
bpy.ops.object.mode_set(mode='OBJECT')Run this script from a Text Editor. The operator needs a UV Editor context in some versions, so if it reports that the context is wrong, run it from a UV Editor area, or use the menu entry instead.
The workflow order
Scaling changes how much room the islands take, so do it before packing. If you pack first and then average the scale, the islands change size and may overlap or run off the image.
Apply object scale first
Average Islands Scale measures the mesh in its own space. If the object has a non-uniform scale, such as 1, 1, 3 in Object Mode, the mesh looks bigger than the operator thinks. The test grid then shows stretched squares even though the UV numbers look fine. Apply the scale with Object > Apply > Scale before you unwrap. My measurement script avoids this problem because it uses the world matrix, but the operator does not.
Image shape matters
Density in U and V is only equal when the image is square. A 2048 x 1024 image has twice as many pixels along U as along V. Blender's UV Editor shows the UVs in the image's proportions when that image is loaded in the editor. An island that looks square in a square view will then stretch when it is placed on the wider image.
For a first project, use square images. If you need a non-square image, load it in the UV Editor so the editor shows the real shape, and check with the test grid at the same aspect ratio. Change IMAGE_SIZE in the script to separate widths and heights if you extend it.
Choosing different densities on purpose
Uniform density is a default, not a law. You may want to vary it:
| Situation | Density choice |
|---|---|
| Hero object seen close up, such as a character's face | Higher than the rest of the model |
| Floors and walls seen from far away | Lower |
| Hidden faces, such as the underside of a table | Very low, or shrink the islands to a small area |
| Repeated patterns, such as tiling brick | Set by how many tiles you want, not by Average Islands Scale |
After Average Islands Scale, scale the chosen islands up or down as a group with S in the UV Editor. Keep the ratios deliberate and note them, so you can reproduce them later. Scale uniformly and avoid pulling one axis, which adds stretching.
Common errors
- Islands look the same size but squares differ. The object has unapplied non-uniform scale. Apply scale and re-run Average Islands Scale.
- Only some islands changed. The operator works on selected UVs. Select all UVs first, and note whether UV Sync Selection is on or off.
- Average Islands Scale shrank everything. Islands were adjusted relative to one another, and the result no longer fills the image. This is expected. Pack afterward to fill the space.
- The script prints a very large ratio. One or more faces may be nearly collapsed in UV space, or an island may be stretched. Check with the stretch overlay for degenerate faces, and look at the test grid.
- Mirrored or overlapping islands read as correct. Overlap is a valid technique for symmetric parts, since both halves share texels. The script measures each face separately, so overlap does not change its numbers. It does change what you can paint, because both halves show the same paint.
Summary of the working model
Every face has a 3D area and a UV area. Texel density is the square root of their ratio, multiplied by the image size. To keep it consistent, apply object scale, unwrap, average the island scale, then pack and verify with a grid. Vary density only when you have a reason, such as a close-up hero area or a hidden surface.
Exercise
A 2048 px square image holds one island for a floor and one for a table. The floor island spans 0.6 of the U axis and is 6 m wide. The table island spans 0.15 of the U axis and is 0.75 m wide. Compute each texel density in px/m, say which object looks sharper, and name the operator you would use to even them out.
Show answer
Floor: 0.6 x 2048 = 1228.8 px across 6 m, so about 205 px/m. Table: 0.15 x 2048 = 307.2 px across 0.75 m, so about 410 px/m. The table has twice the density of the floor, so it looks sharper. Select both islands in the UV Editor and use UV > Average Islands Scale, then pack the islands and check again with a test grid.