Why the colours are exact
The claim is that the hex shown in the panel is the hex in the exported file, so a magic wand at tolerance 0 selects a whole material. Three separate things in Blender break that, and each is handled.
Problem | Effect on a flat pass | Handling |
|---|---|---|
View transform | Blender's default AgX is a filmic tone map. It repaints every flat colour into something else. | The exported file's colour management is overridden to Standard/sRGB. Your beauty render is unaffected. |
Dithering | | Forced to 0 for the duration of the ID render, then restored. |
Pixel filter | Anti-aliasing averages across pixel edges, so edge pixels hold a blend of two materials. | Crisp Edges renders with one sample and no pixel filter. |
On top of that, the colour fed to the shader is the exact inverse of the sRGB encode the file is written with, so the value round-trips back to the byte you were shown.
What this looks like when it works: a 900×600 render of seven materials, including a sphere, a torus and a cone, contains exactly eight distinct colours — seven materials plus the black background. Every material covers an identical pixel count, which is what proves no edge pixel was averaged into a blend.