Sub topic 3
Packing Islands and Finishing the Texture Setup
This chapter assumes you can unwrap a mesh in the UV Editor, know how Edit Mode and Object Mode differ, and have connected an Image Texture node to a Principled BSDF.
Packing islands into the image space
An island is a group of faces that stays connected after you cut seams and unwrap. Packing arranges these islands inside the 0 to 1 UV square so they do not overlap and use the image evenly. Scale islands to a consistent size first, then pack them. Otherwise a small island gets the same space as a large one and receives too few texels.
Keep a margin between islands. A margin of about 0.005 stops colors from one island bleeding into its neighbor when the texture is filtered.
Choosing the right color space for each image
A color space tells Blender how to read the numbers in an image file. Use sRGB for color images such as albedo or base color maps. Use Non-Color for data images such as roughness, metallic, or normal maps. Reading a data map as sRGB brightens and shifts its values, which changes the shading.
Mapping, interpolation and extension settings
Interpolation decides how Blender blends texels when the image is scaled. Linear gives smooth results. Closest keeps sharp pixels, which suits pixel art.
Extension decides what happens outside the 0 to 1 range. Repeat tiles the image. Clip shows nothing outside the square.
Saving or packing the image with your file
An unpacked image is a link to a file on disk. If that file moves, the texture goes missing. Packing stores the image inside the .blend file so it travels with the scene.
Automating the workflow with Python
The script below packs the islands, sets the color space and the texture options, and packs the image. It assumes the active object is a mesh with a UV map and that the image exists at the path shown.
import bpy
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.uv.pack_islands(margin=0.005)
bpy.ops.object.mode_set(mode='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"
tex.interpolation = 'Linear'
tex.extension = 'REPEAT'
tex.image.pack()
links.new(tex.outputs["Color"], bsdf.inputs["Base Color"])
obj.data.materials.append(mat)Exercise
A roughness map looks too bright and washed out after you load it. Which color space should you check, and what should it be set to?
Show answer
The color space is probably set to sRGB. A roughness map holds data, not color, so set it to Non-Color.