PBR Texture Sets
Modern engines shade surfaces with physically based rendering (PBR): a material describes physical properties (how rough, how metallic, what colour) and the lighting model does the rest. Artists deliver a texture set per material, and most import problems with PBR come from three things a programmer can check: which maps exist, which colour space each one is in, and how channels are packed.
The shading math is covered in Shaders & Graphics Programming; this lesson is about the files.
The maps of the metallic-roughness workflow
| Map | Contents | Colour space | Notes |
|---|---|---|---|
| Base colour (albedo) | surface colour, no lighting or shadows baked in | sRGB | metals put their reflection colour here |
| Normal | per-pixel surface direction in tangent space | linear | blue-ish purple; never mark as sRGB |
| Metallic | 0 = dielectric (plastic, wood), 1 = metal | linear | mostly pure black or white |
| Roughness | 0 = mirror, 1 = matte | linear | Unity uses smoothness = 1 − roughness |
| Ambient occlusion | how hidden each point is from ambient light | linear | |
| Emissive | light the surface gives off | sRGB | |
| Height | displacement for parallax or tessellation | linear | optional |
glTF 2.0 standardises this workflow, which is one reason it imports so cleanly into Godot and three.js (see glTF vs FBX).
Colour space: the most common mistake
Colour textures are stored in sRGB (gamma-encoded, to spend more bits on dark tones, where our eyes are sensitive). Data textures (normals, roughness, metallic, masks) store numbers, so they must be read linearly. If a roughness map is imported as sRGB, the GPU "decodes" it and every value except 0 and 1 shifts:
def srgb_to_linear(c):
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
for stored in [0.0, 0.25, 0.5, 0.75, 1.0]:
wrong = srgb_to_linear(stored)
print(f"roughness stored {stored:.2f} -> read as {wrong:.3f} if the texture is wrongly marked sRGB")roughness stored 0.00 -> read as 0.000 if the texture is wrongly marked sRGB
roughness stored 0.25 -> read as 0.051 if the texture is wrongly marked sRGB
roughness stored 0.50 -> read as 0.214 if the texture is wrongly marked sRGB
roughness stored 0.75 -> read as 0.523 if the texture is wrongly marked sRGB
roughness stored 1.00 -> read as 1.000 if the texture is wrongly marked sRGB
A surface meant to be half rough (0.5) renders at about 0.21: shiny plastic where there should be dull paint. In Unity, untick sRGB (Color Texture) on data textures; in Unreal, untick sRGB or use a matching Compression Settings (Normalmap, Masks); in Godot, data textures are detected from their use in a material, but check the import dock if a mask looks wrong.
Normal maps: OpenGL vs DirectX
Tangent-space normal maps come in two conventions that differ only in the green channel:
| Convention | Green means | Used by |
|---|---|---|
| OpenGL (Y+) | up | Blender, Unity, Godot, glTF |
| DirectX (Y−) | down | Unreal Engine |
A map in the wrong convention makes bumps look like dents when lit from above. Converting is a channel flip (g = 1 − g); Unreal's texture editor also has a Flip Green Channel checkbox. Ask artists which convention their baker exported.
Channel packing
Metallic, roughness and AO are single-channel images. Storing each in its own RGB texture wastes two thirds of the memory and three texture samples. Engines pack them into the channels of one texture, but the layouts differ:
| Engine / standard | R | G | B | A |
|---|---|---|---|---|
glTF 2.0 (metallicRoughnessTexture + occlusion) |
occlusion | roughness | metallic | – |
| Unreal (common "ORM" convention) | occlusion | roughness | metallic | – |
| Unity URP Lit (Metallic Map) | metallic | – | – | smoothness |
| Unity HDRP Lit (Mask Map) | metallic | occlusion | detail mask | smoothness |
Godot ORMMaterial3D |
occlusion | roughness | metallic | – |
A pipeline script that re-packs one source set for each engine looks like this (with a tiny four-pixel "image" so you can see every value):
roughness = [0.9, 0.5, 0.2, 0.7]
metallic = [0.0, 0.0, 1.0, 1.0]
occlusion = [1.0, 0.8, 1.0, 0.6]
def to8(x):
return round(x * 255)
def pack_orm():
return [(to8(o), to8(r), to8(m)) for o, r, m in zip(occlusion, roughness, metallic)]
def pack_unity_urp():
return [(to8(m), 0, 0, to8(1 - r)) for r, m in zip(roughness, metallic)]
print("ORM (glTF / Unreal / Godot):", pack_orm())
print("Unity URP metallic map :", pack_unity_urp())
normal_gl = [(128, 200, 255), (90, 128, 240)]
normal_dx = [(r, 255 - g, b) for r, g, b in normal_gl]
print("normal GL -> DX :", normal_gl, "->", normal_dx)ORM (glTF / Unreal / Godot): [(255, 230, 0), (204, 128, 0), (255, 51, 255), (153, 178, 255)]
Unity URP metallic map : [(0, 0, 0, 25), (0, 0, 0, 128), (255, 0, 0, 204), (255, 0, 0, 77)]
normal GL -> DX : [(128, 200, 255), (90, 128, 240)] -> [(128, 55, 255), (90, 127, 240)]
In production you would do the same with Pillow, ImageMagick, Substance's export presets or the engine's own import scripts; the logic is exactly this.
A texture-set checklist
- Every map of a set has the same resolution and the same UV layout.
- Names follow one convention, for example
T_Crate_BaseColor.png,T_Crate_Normal.png,T_Crate_ORM.png(Unreal style) orcrate_albedo.png,crate_normal.png. - Base colour has no baked lighting; metals are bright, not dark grey.
- Data maps are imported as linear, normal maps as normal maps.
- Normal-map convention matches the engine.
- Packed maps match the engine's channel layout.
Validating Assets Automatically turns this list into a script.
Test yourself
Which texture should be imported as sRGB?
- Normal map
- Roughness map
- Base colour (albedo)
- Metallic map
Bumps on a wall look like dents in Unreal, but looked right in Blender. What is the likely fix?
- Increase roughness
- Flip the normal map's green channel (OpenGL to DirectX convention)
- Mark the normal map as sRGB
- Add a second UV set
Unity's URP Lit shader reads smoothness from the metallic map's alpha. How do you get it from a roughness value?
- smoothness = roughness
- smoothness = 1 - roughness
- smoothness = roughness squared
- smoothness = metallic