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?

  • $\begingroup$ 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? $\endgroup$ – FFeller Oct 3 '19 at 16:22
  • $\begingroup$ 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. $\endgroup$ – clankill3r Oct 3 '19 at 16:52
  • $\begingroup$ I thought "blender render" was "workbench" in 2.8. Can you just use workbench? $\endgroup$ – dave44 Oct 3 '19 at 17:27
  • $\begingroup$ 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. $\endgroup$ – FFeller Oct 3 '19 at 17:58
  • $\begingroup$ 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. $\endgroup$ – Millard Oct 3 '19 at 20:05

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.

| improve this answer | |
  • $\begingroup$ Thanks, I will upvote you once my answer is at the top $\endgroup$ – clankill3r Oct 3 '19 at 18:35
  • $\begingroup$ This looks as if it might be the correct answer to this recent question too? $\endgroup$ – Robin Betts Oct 3 '19 at 20:42
  • $\begingroup$ @RobinBetts yes it does. The HSV value without gamma correction would be (0.0, 0.0, 0.5) and with gamma correction (0.0, 0.0, 0.735357) $\endgroup$ – Robert Gützkow Oct 3 '19 at 21:34

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.