Skip to content

TheoryDeepPixels

Cary Phillips edited this page Oct 31, 2019 · 1 revision

The Theory of OpenEXR Deep Samples

Peter Hillman Weta Digital Ltd

May 16, 2018

AbstractThis document derives the techniques for splitting and combining two non-solid samples of equal depth and thickness. These should should be used by deep image ‘flattening’ algorithms to compute the combined colour of two samples. The formulas are defined in the document “Interpreting OpenEXR Deep Pixels” by Florian Kainz. This document derives those formulas, and is for information only.

This is an amendment to the November 2013 version with corrections for equations 6 and 7.

Contents

1 Sample model 21.1 AlphavsTransparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Computing t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Sampleproperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Sample splitting 42.1 Alphaofasubsample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 Colourofasubsample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 Splittingtransparentsamples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Sample merging 63.1 Mergingwhenonesampleistransparent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.2 Mergingtwotransparentsamples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.3 Mergingsolidsamples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Summary 8

Definitions

r ratio of length of original sample to a subsample: 0 ≤ r ≤ 1 Ci Colour of sample iC iColour of a subsample of i αi alpha value of sample iα ialpha value of a subsample of i Ti transparency/transmission of sample i; Ta = 1 − αaci colour per unit length (‘instantaneous colour’) of iti transparency per unit length (‘intenstaneous transparency’) of i

Subscripts a and b refer to the input samples; subscript c refers to the combined output sample

2

Figure 1: Light passing through multiple objects from left to right. Each object attenuates a fraction t of the light

1 Sample model

Many deep compositing operations require subdividing a sample into two subsamples, or else clipping a sample at a given point. When this happens, the alpha value of the subsample(s) must be recomputed, and the colour will also change. To derive an equation for computing the new alpha, the amount of light attenuated by each subsample must be considered.

Light passing through a light absorbing object will by attenuated according to the transparencyt of the ob- ject. Thus, if i is the amount of light entering the object, the light o leaving the object is given by

o = t · i (1)

Where light passes through two objects, as in Figure 1, the light is attenuated twice (the output from the first is fed into second)

o = t2 · (t1 · i) (2)where t2 and t1 are the transmission of the individual samples. In general, if the transmission t of all objects are the same, the light emerging from n adjacent samples is given by the Beer-Lambertlaw:

o = i · tn(3) T = oi = tn(4)

where T is the total transmission. If t is considered the transmission per unit lengthand n the length, the equation is continuous, applying also for non-integer values of n1.

An OpenEXR deep sample can then be modelled as an object of a specified length n which absorbs light according to equation (4).

1.1 Alpha vs Transparency

OpenEXR images use alpha α instead of transparency. T = 1 − α: if α = 1 (so T = 0) then all light is absorbed; if α = 0 (so T = 1), then all light is transmitted and the material is transparent. Substituting T into (1) and (2) gives the screencompositing operation:

αc = 1 − (1 − α1)(1 − α2) (5)

1Various forms of the Beer-Lambert law exist, using different constants. For example, o = i · 10−εlc, where ε and c are the molarabsorptivity and concentration respectively. This is equivalent to (4) if t = 10−εcand l = n

3

where αc is the combined alpha value, and α1 and α2 are the alpha values of the two samples.

Throughout this document, T is preferred to α where it gives simpler equations.

1.2 Computingt

OpenEXR images samples store the α of the entire sample. This gives us the total transmission T of the sample, not the transmission per unit length t. Rearranging (4) gives

Clone this wiki locally