Sub topic 2
Putting an Image on a Material with the Image Texture Node
This chapter assumes that you can navigate the Blender viewport, switch between Object Mode and Edit Mode, select mesh components, and create a basic material. You should also know that the mesh needs a UV map before an image can follow its surface predictably.
How an Image Texture Works
An image texture is a node that reads pixels from an image file. A material shader then uses those pixels to control a surface property, such as Base Color.
A UV map is a set of 2D coordinates stored on a mesh. The coordinates tell Blender which part of the image belongs at each face corner. The letters U and V are used instead of X and Y because the image coordinates describe a separate texture space.
The Image Texture node has several important connections:
| Node or setting | Purpose |
|---|---|
| Image Texture | Reads pixel data from an image |
| Vector input | Chooses where Blender samples the image |
| Color output | Sends the sampled color to another node |
| Extension | Controls what happens outside the 0–1 UV range |
| Interpolation | Controls how pixels are filtered |
For a normal color image, connect the node's Color output to the Principled BSDF node's Base Color input. The Principled BSDF is Blender's general-purpose shader for common materials.
Add the Image Texture Node
- Select the object and open the Shading workspace.
- Create or select a material.
- In the Shader Editor, press
Shift+A. - Choose Texture > Image Texture.
- Click Open on the Image Texture node and select an image.
- Connect Color from Image Texture to Base Color on Principled BSDF.
The image may look stretched or appear on the wrong faces. That result usually comes from the UV map, not from the material node. The node can only use the UV coordinates it receives.
To select a UV map explicitly, add a UV Map node and choose the required map from its dropdown. Connect its UV output to the Image Texture node's Vector input. If the Vector input is empty, the Image Texture node normally uses the active UV map automatically.
Load an Image with Python
The following script creates a material, loads an image from a path relative to the .blend file, and connects the image to Base Color. The // prefix means that the path is relative to the saved Blender file.
import bpy
obj = bpy.context.active_object
if obj is None or obj.type != 'MESH':
raise RuntimeError("Select a mesh object before running this script.")
mat = bpy.data.materials.get("TexturedMaterial")
if mat is None:
mat = bpy.data.materials.new("TexturedMaterial")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
bsdf = nodes.get("Principled BSDF")
if bsdf is None:
raise RuntimeError("The material has no Principled BSDF node.")
tex = nodes.get("Image Texture")
if tex is None:
tex = nodes.new("ShaderNodeTexImage")
tex.image = bpy.data.images.load("//textures/brick_color.png", check_existing=True)
tex.image.colorspace_settings.name = "sRGB"
links.new(tex.outputs["Color"], bsdf.inputs["Base Color"])
if obj.data.materials:
obj.data.materials[0] = mat
else:
obj.data.materials.append(mat)The check_existing=True option prevents Blender from loading a second copy of the same image when the script runs again. The sRGB setting is correct for an image that represents visible color. Other image types, such as roughness or normal maps, need different color-space settings.
Check the Result
Switch to Material Preview or Rendered view. Look for these symptoms:
- A solid color may mean the image is missing or disconnected.
- A black or pink surface may indicate a missing image file.
- Repeated patterns may mean the UV coordinates extend outside the 0–1 image area.
- Severe stretching usually means the mesh needs a better unwrap.
- A rotated image may require editing UV islands in the UV Editor.
Save the .blend file after loading the image. The material stores a reference to the image, but it does not automatically store the image pixels inside the blend file.
Exercise
Which connection makes an image control the visible color of a material?
Show answer
Connect the Image Texture node's Color output to the Principled BSDF node's Base Color input.