Negative Colors

I am currently working on a neural denoiser for Cycles, that’s why I statistically analyze all sorts of data from Cycles. So far, I assumed that all the colors in Cycles are positive or zero. But the EXRs for the training contain plenty of negative colors, especially in the direct/indirect glossy/diffuse passes.

Is there an issue in my data or in the way I analyzed the data?
If not, is there any kind of clamping going on during the compositing or are combinations of the passes always positive, like direct + indirect >= 0 or maybe color * (direct + indirect) >= 0?

No. Negative values will arise under a number of different circumstances, not limited to:

  • Negative values due to sampling
  • Negative values due to gamut transformations
  • Negative values due to various math operations

Clamping should always be performed by the pixel pusher on a need to need basis. If the excursion is legitimate, it may need to be retained until a follow up operation occurs for example.

Thanks for the answer.

I should have used the term ‘Combined’ instead of ‘Composed’ to avoid confusions. The passes are combined as described in this document:
The misunderstanding was that the raw Cycles output only contains positive color values. My question is whether any combination of those passes always produces positive color values.

Would likely depend on what values are fed into it.

That’s not something I can choose, because I have to consider all possible cases. Because you mentioned that negative values can also occur due to the sampling, I had to rethink some parts and was able to come up with another solution that works with positive and negative inputs. Thanks again!

Received some questions regarding negative values that would probably be well suited to post here for posterity:

It should be noted that in most cases, when a value extends beyond the encoding limits of the encoding model, the data becomes non-data. One should always evaluate if the negative values represent anything in the encoding system they are manipulating the data.

A quote from Jeremy Selan’s excellent Cinematic Color [PDF]:

While a full discussion of input characterization is outside the scope of this document, there are differing philosophies on what camera linearizations should aim to achieve at very darkest portions of the camera capture range. One axis of variation is to decide if the lowest camera code values represent “true black,” in which the average black level is mathematically at 0.000 in scene-linear, or if instead the lowest camera code values correspond to a small but positive quantity of scene-linear light. This issue becomes more complex in the context of preserving sensor noise/film grain. If you consider capturing black in a camera system with noise, having an average value of 0.000 implies that some of the linearized noise will be small, yet positive linear light, and other parts of the noise will be small, and negative linear light. Preserving these negative linear values in such color pipelines is critical to maintaining an accurate average black level. Such challenges with negative light can be gracefully avoided by taking the alternative approach, mapping all sensor blacks to small positive values of linear light. It is important to note that the color community is continues to be religiously split on this issue. Roughly speaking, those raised on motion-picture film workflows often prefer mapping blacks to positive linear light, and those raised on video technology are most comfortable with “true black” linearizations.


Wow, that’s amazing! Thanks a lot for those detailed information. I really appreciate it!