Inaccurate results when saving MaterialIDs to OpenEXR and loading them back into Blender
Closed, ArchivedPublic

Description

System Information
Windows 7, 64 bit, Quadro 4000

Blender Version
Broken: 2.79 and following
Worked: unknown

Short description of error
I have a demo scene with around 3000 different MaterialIDs. When rendering the MaterialID pass and saving it out to OpenEXR Multilayer, and then read back in the file, the IDs between a Float (Half) and Float (Full) image are different. It seems like there are rounding errors. We did not notice such behavior when using a lower number of different IDs so far. I'm not sure if this really is a bug or a technical limitation, but I thought that Float (Half) should be able to store 65536 different IDs per channel no problem.

Exact steps for others to reproduce the error
Download the .blend file. Open it and hit F12 to render. Now, the image nodes should read the rendered EXR files back in. In the Image Editor, hold down the Mouse Button to see the Material Index Values. When previewing the floatHalf one, you'll notice that uneven indicies are mostly missing. The floatFull offers all of them.

blend file:

Details

Type
Bug
ronan ducluzeau (zeauro) triaged this task as Confirmed priority.Nov 23 2017, 2:39 PM

I can confirm the problem on ubuntu 16.04 with 2.79 and master f2842ac .

Float(Half) is storing uneven number until 2045. There is one cube corresponding to 2046. Then, 2 cubes corresponding to 2048,2050, 2052, etc...

Half floats can store maximum 65536, but definitely not all integers in between. I think we should always store ID passes with full float precision, regardless if the half float option is used.

See also "precision limitations on integer values" here:
https://en.wikipedia.org/wiki/Half-precision_floating-point_format

An extra problem in this .blend is that it's using a file output node, and that currently doesn't have a way to specify the channel output type (XYZ, RGB, ..), so we can't auto detect it. It would be good to add that, but regardless, best not to try saving IDs as half float. When saving a multilayer EXR directly from the render we can detect it though.

Brecht Van Lommel (brecht) claimed this task.