Sub topic 7
Setting Non-Color Data for Baked Maps
This chapter assumes you can create an image in Blender, add an Image Texture node in the Shader Editor, and unwrap a low-poly mesh. You should also know the difference between a color value and a direction stored in a texture. The chapter covers why normal and ambient occlusion (AO) maps must be marked as Non-Color, where to set that, what happens when you get it wrong, and how to check it.
Why color space matters for data
Blender stores image pixels as numbers. Before it uses those numbers, it applies a color space, which is a rule that converts stored values into the values the renderer works with. Most color images, such as a painted albedo texture, are stored in sRGB. sRGB is a curve that spends more of its range on dark tones, because that matches how people see brightness. When Blender reads an sRGB image, it converts the pixels to linear values first.
A baked normal map is not a picture. Each pixel holds a direction, with the X, Y and Z parts of a vector packed into the red, green and blue channels. An AO map holds a occlusion amount from 0 (fully blocked) to 1 (fully open). If Blender applies the sRGB curve to these values, it changes the numbers. The direction tilts and the occlusion amounts shift. Nothing looks obviously broken, which makes this a quiet error.
The setting that tells Blender to leave the numbers alone is Non-Color. It applies no conversion, so the value stored is the value used.
| Image type | Stores | Color space |
|---|---|---|
| Albedo or base color | Visible color | sRGB |
| Tangent-space normal map | Direction vectors | Non-Color |
| Ambient occlusion map | Occlusion amount | Non-Color |
| Roughness, metallic, height | Scalar data | Non-Color |
Where to set it
The color space belongs to the image, not to the node or the material. You can set it in two places, and both change the same property.
- In the Shader Editor, select the Image Texture node. Under the image name, open the Color Space drop-down and choose Non-Color.
- In the Image Editor, open the sidebar with N, go to the Image tab, and set Color Space there.
Set it before you bake. When you bake to an image, Blender writes the result into that image's pixels using the image's current settings. Changing the color space afterward only changes how the stored pixels are interpreted. It does not repair a bake that was made with the wrong setting in some cases, and it can leave you unsure which state the file is in. Setting it first removes the doubt.
Bake output and the image's color space
The Bake panel in Cycles does not ask you for a color space. For a data bake such as Normal, Blender writes the values directly and the target image's color space decides how they are read back. For Diffuse or Combined bakes, the situation differs, because these are color results, so you would normally keep sRGB for them. This chapter deals only with the data maps, which are Normal and AO.
AO deserves a note. In the Bake panel, Ambient Occlusion is a bake type that produces a grayscale result. It is a measurement, so treat it as data. If you later multiply it into a color texture, that is a separate decision made in the material, and the AO image itself should still be Non-Color.
Setting it in a script
The first two code examples in this tutorial set the color space as soon as they create the image. This is the pattern to follow, because it makes the order impossible to get wrong.
import bpy
def new_data_image(name, size=2048):
"""Create a bake target that is marked as data from the start."""
img = bpy.data.images.new(name, size, size)
img.colorspace_settings.name = 'Non-Color'
return img
normal_img = new_data_image("Asset_normal")
ao_img = new_data_image("Asset_ao")
for img in (normal_img, ao_img):
print(img.name, img.colorspace_settings.name)Running this prints two lines, each ending in Non-Color. The property colorspace_settings.name accepts the same names that appear in the drop-down.
A 2048 by 2048 image created this way has 8 bits per channel by default and is saved as PNG in the scripts of this tutorial. That is enough for most game-ready normal maps. If you see banding in smooth gradients, a 16-bit PNG or a float image can help, but that is a quality choice and is separate from color space.
What the error looks like
A wrong color space does not produce an error message. Look for these symptoms.
- Normal map set to sRGB. The map is read through the wrong curve, so surfaces that should be flat show a slight tilt. Shading looks too strong or too washed out, and lighting changes seem to lean in one direction. A flat area of a tangent-space map should be a pale blue of roughly (0.5, 0.5, 1.0). With the wrong curve, that blue is converted to different values and the "flat" direction is no longer flat.
- AO set to sRGB. Midtones in the occlusion look lighter than they should. Crevices are less dark, so the map seems weak.
- Data map used with the wrong node setup. If you plug a Non-Color normal image straight into the Principled BSDF Normal socket, skipping the Normal Map node, the result is also wrong. That is a different problem and is covered in the chapter on applying the maps.
A checking routine
Use this short routine every time you create a bake target.
- Create the image with a name that says what it holds, such as
Asset_normal. - Set its color space to Non-Color immediately.
- Add an Image Texture node to the low-poly material and assign the image.
- Click the node so it is the active node. Blender bakes into the active Image Texture node.
- Bake, then save the image. Packing or saving does not change the color space.
- Reopen the image and read the Color Space field again.
Step 6 matters when you reload files. If you save a PNG and then open it from disk in a new session, Blender may guess its color space from the file. Check that the value is still Non-Color. In a script, you can assert it.
import bpy
for name in ("Asset_normal", "Asset_ao"):
img = bpy.data.images[name]
assert img.colorspace_settings.name == 'Non-Color', (
f"{name} is {img.colorspace_settings.name}, expected Non-Color"
)
print("Bake targets are data images.")Edge cases
- Reusing one image for several bakes. If you bake AO into an image that was created as a color image, the image keeps its sRGB setting. Always make a new image per map, or change the setting and re-bake.
- Importing an existing map. A normal map you load from disk starts with the default color space for that file. Change it to Non-Color by hand.
- Exporting for a game engine. The engine reads the file on its own terms. Most engines have a separate flag for "this is a normal map" or "sRGB on or off". Blender's Non-Color setting does not travel with the PNG, so set the flag in the engine as well.
- Color management view transform. The Filmic or AgX view transform only affects what you see in the viewport and in renders of color. It is not the same as the image's color space, and changing it does not fix a data map.
Exercise
You bake a tangent-space normal map and the low-poly mesh looks slightly tilted and over-shaded under a light. The Image Texture node reads sRGB. List the steps you take to fix it, and say whether you must re-bake.
Show answer
Select the Image Texture node, change Color Space from sRGB to Non-Color, and check that the Normal Map node is in the chain. Setting the image to Non-Color makes Blender read the stored values directly, which usually fixes the tilt without a new bake. If the image was saved or edited while it was sRGB, or you are unsure, re-bake into a new image that was set to Non-Color before baking, and compare the two results.
Exercise
Why does the AO map also need to be Non-Color, even though it looks like an ordinary grayscale picture?
Show answer
The AO map stores a measured occlusion amount, not a visible color. The sRGB curve would change those amounts, so midtones would read lighter and crevices would look weaker than they were baked. Non-Color keeps the numbers unchanged.