2

I wan't to create a segmentation map for machine learning. For that I have a list of colors like:

clouds  #aaaaaa
cow     #4f445b
grass   #1dc331

It is from absolute importance that the render has the exact same colors.

I tried: enter image description here

And: enter image description here

But in the render the colors are off. How can I get a render with the exact colors I give?

clankill3r
  • 1,191
  • 1
  • 12
  • 32
  • Simpliest way if you download Blender 2.79 and use the Blender Render engine. It has a shadless option for the materials. / Did you try the emission shader only? – FFeller Oct 03 '19 at 16:22
  • I don't want to jump between 2.79 and 2.8, part of why am doing this is getting into blender 2.8. Using the emission shader only has the same result. – clankill3r Oct 03 '19 at 16:52
  • Dave44 said well. I didn't know, but workbench is the same as Blender Render. Just use "Flat" for lighting in the Render properties tab. – FFeller Oct 03 '19 at 17:58
  • I thought "blender render" was "workbench" in 2.8. Can you just use workbench? – dave44 Oct 03 '19 at 17:27
  • workbench isn't the same as blender render, at least I don't think it is. It's basically a engine used for open GL renders. It would work well in this case. – Millard Oct 03 '19 at 20:05
  • Are you sure the colors are off? They were the same when I tried it. – Millard Oct 03 '19 at 20:07
  • @millard Did you use eevee? – clankill3r Oct 03 '19 at 20:25
  • yes. I tested it, by clicking on my rgb color in the node panel, selecting the tear drop tool, and pressing on the object in the rendered image. the color didn't change, so I knew that it was the same. – Millard Oct 03 '19 at 22:59

2 Answers2

4

There are mainly four steps you should take, when following your approach with emissive materials in Eevee:

  1. In the Color Management panel, set the View Transform to Raw (if you're not saving as OpenEXR)
  2. Use the RGB slider to set the color values or be aware of gamma correction
  3. Be aware of floating point inaccuracies or use OpenEXR as file format with Float(Full)
  4. Disable anti-aliasing

The first point ensures that the exact scene referred values are stored without mapping them to different values through the view transform. The filmic view transform would be useful for realism when rendering a scene, but not for non-color data such as masks.

The second point ensures that you don't get confused with the gamma correction. By setting it through the RGB slider, you're directly entering the values used in the scene without gamma correction as explained in the manual. The output will therefore contain these exact values when using the raw view transform as long as the image format can represent them. You can use the hex values, but be aware that they are interpreted as gamma corrected. This is common practice, but I've seen people get confused by this.

In Blender, the Hex and HSV/HSL values are automatically gamma corrected however, for the RGB values, they are in Scene Linear color space, and are therefore not gamma corrected. For more information, see the Color Management and Exposure page.

The third point ensures that the selected color value can be accurately represented in the image format and is exactly the floating point value you chose in the color picker. If you use OpenEXR, you don't have to set the View Transform to Raw because it already stores the raw values. Of course you can choose a different image format, but it may not be able to represent the color accurately because of lower floating point precision or because it uses the [0-255] range per color channel.

The last point ensures that only the exact colors appear in the image an no blending between colors happens in adjacent areas. When using Eevee set the Filter Size in the Film panel to zero, for Cycles select Box Filter.


There are other options to accomplish the same task in the compositor. For instance if you'd be using Cycles, the Cryptomatte would give you masks for objects or materials.

Robert Gützkow
  • 25,622
  • 3
  • 47
  • 78
3

Special thanks to @rjg for somewhat getting me in the right direction.

The dither should be set to 0:

enter image description here

And View Transform to Standard

enter image description here

Bonus picture

enter image description here

clankill3r
  • 1,191
  • 1
  • 12
  • 32