I am trying to bake a map that shows calculated normals in 0..1 range using cycles. (As opposed to -1..1 range)

When I use Separate XYZ -> Map Range -> Combine XYZ, normal components that should be 0.5 (originally 0) end up being 0.7373.

I can confirm these values are 0.5 using test nodes. (Please see the blend file)

enter image description here

Changing color management from filmic to standard didn't help. It seems color management is not taken into account at all during bake.

Appreciate any help in fixing this. But more importantly I would like to understand where 0.7373 value comes from.

  • 2
    $\begingroup$ Perhaps this answer could help you. $\endgroup$ – Robert Gützkow Feb 9 '20 at 11:48
  • $\begingroup$ @RobertGützkow thanks for the link. It didn't occur to me to convert normals to camera space. Honestly I think it's not the right thing to do. But I'll give it a try nevertheless. $\endgroup$ – muhuk Feb 9 '20 at 11:57
  • $\begingroup$ Whether it's the right thing to do depends on the goal you're trying to achieve. The problem you're seeing is most likely caused by color management. Either save the file as OpenEXR or use Raw as view transform for non-color data. $\endgroup$ – Robert Gützkow Feb 9 '20 at 11:59
  • $\begingroup$ Using Raw as view transform doesn't change the resulting values. $\endgroup$ – muhuk Feb 9 '20 at 12:56
  • $\begingroup$ Then I'll have to take a closer look at your node setup. $\endgroup$ – Robert Gützkow Feb 9 '20 at 12:57

Note: This is only a partial answer, since more information were provided in the comments after it was written. Color management is nonetheless relevant for a correct output.

The reason your correct value of $0.5$ is saved as $0.735357$ is because you're using the Standard view transform and your Display Device is set to sRGB.

The scene linear values are transformed into the sRGB color space (IEC 61966-2-1:1999). During this process gamma correction is applied.

$$\gamma_{sRGB}(x) = \begin{cases} 12.92x,& x \le 0.0031308\\ 1.055 x^{\left(\frac{1}{2.4}\right)} -0.055 , & \text{otherwise} \end{cases}$$

For an input of $x=0.5$ this results in $1.055 \times 0.5^{\left(\frac{1}{2.4}\right)}-0.055=0.735357$

In order to save the scene linear values use the OpenEXR (.exr) format. Blender will not apply any view transforms or display transforms when using this format. Alternatively, if you're certain that your output is in the $[0.0, 1.0]$ range, you can also set the view transform to Raw and use any other image format to save an approximation of the values. Blender will map the values to the $[0,255]$ range automatically.

  • 1
    $\begingroup$ I'm always confused about where to get the knife in: what mappings are used at what points in the pipeline... Could you briefly go over the correct settings to save linear values in this answer? $\endgroup$ – Robin Betts Feb 9 '20 at 12:31
  • $\begingroup$ I can change the Display Device to None, then the only option is Standard view transform. When I bake under these settings I still get the same result though. $\endgroup$ – muhuk Feb 9 '20 at 12:51
  • 1
    $\begingroup$ @RobinBetts as longs as you're working with values within Blender it should all be in scene linear. The transforms are only applied once you save the image as file or when displaying it on your monitor. $\endgroup$ – Robert Gützkow Feb 9 '20 at 13:05
  • $\begingroup$ @muhuk What exactly do you mean by baking in this context? What steps do you perform that give you the output image? If you want to bake a normal map, then you can simply set the Bake Type to Normal. $\endgroup$ – Robert Gützkow Feb 9 '20 at 13:23

Thanks to @robert-gützkow I managed to debug the issue.

It turns out the solution is to:

  • Use an emission shader in the material to be baked.
  • Use Combined bake mode instead of Emit. (see image below)

material setup

bake setup


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.