Exposing 78 – Understanding Constants In Exposure Calculations From Real-Time Graphics

The Introduction

Recently, I’ve been doing a bit of extra research into exposure in the context of physically based rendering. Primarily, I was looking to strengthen my understanding of the underlying concepts and values involved. This post can perhaps be described as a diary and something of an explainer? Either way, here we go!

The Intuition

When we want to capture a scene with some lights involved, we will likely end up capturing surfaces with luminance values far above 1. If we were to simply take these values and output them to our screen, it is likely you might end up with a scene that is primarily white. Unless your desired aesthetic is completely blown out lighting, this is likely not desirable. To handle these values and remap them to a more acceptable range you might want you camera to adjust to the brightness of the scene in order to translate the brightness of your scene from 0->VeryBright to something more reasonable.

To achieve this you could simply find the brightest point in your scene, and remap every value with Exposure = 1/MaxLuminance. Unfortunately, this means that if you have a small surface in your scene with a brightness of 1000 and the rest of your scene in the range of 0->10, the majority of your scene will have a brightness of 0.01! Perhaps this is your desired aesthetic but I will assume that it is not.

There is a huge amount of possibility here (maybe there’s some neat new ideas that could make for some very cool looks!), however for this post we will use the approach described in [1]. This approach makes use of the scene’s average luminance to determine the maximum luminance that we want to allow for our capture. As a result, all values above this maximum luminance will have values above 1 and will become pure white while our other values will be remapped to values between 0 and 1.

To do this, we can convert our average luminance to our desired maximum luminance with MaxLuminance = 9.6AverageLuminance (Where we get this formula will be explained in time). This approach is informed by Saturation Based Sensitivity and we will use it’s concepts to reach this formula (and others like it).

Saturation Based Sensitivity assumes that our camera will reach maximum brightness when the luminance reaching the camera from a surface is 41% brighter than a 100% reflective Lambertian surface (a total reflectivity of 141%). This allows for specular highlights to retain some detail instead of being washed out in perfectly white surfaces.

141% in this case is chosen using Exposure Values which are a unit of brightness largely used in photography. Exposure Values or EV represent values that grow exponentially. Where an EV of 2 is twice as bright as an EV of 1. 141% is the brightness of half an EV (or a “half-stop”). This can be derived by noting that EVs can be converted to brightness with the formula 2^{EV}=brightness. For half an EV, we can see that our brightness would be 2^{0.5}=\sqrt{2}=1.41 (I use brightness here ambiguously, as EVs aren’t necessarily a scientific unit and this conversion depends on some additional camera parameters that I will not be touching on yet.)

With this in mind, Saturation Based Sensitivity calibrates our sensor so that when a middle grey card (an 18% reflective Lambertian surface) is illuminated in our scene we can determine our maximum luminance reaching the camera as \frac{\sqrt{2}}{MaxLuminanceAtCamera} = \frac{0.18}{MiddleGreyLuminanceAtCamera}.

For future equations, we will reference “LuminanceAtCamera” as H (H_{MiddleGrey} for MiddleGreyLuminanceAtCamera). This is often known as Luminous Exposure which is luminance arriving at our camera sensor modulated by our various camera parameters.

Now that we can determine our maximum luminous exposure from our middle grey exposure with \frac{\sqrt{2}}{H_{Max}} = \frac{0.18}{H_{MiddleGrey}}, we need a way to take our average luminance and turn it into our middle grey luminous exposure.

The Derivation

To begin, we note that we can relate luminance to luminous exposure with:

(1) H = \frac{qt}{N^2}L

Where q is our lens and vignetting attenuation [1][2], t is our shutter time, N controls our aperture width and L is our luminance.

Additionally, we note that we can also calculate our middle grey exposure with:

(2) H_{MiddleGrey} = \frac{10}{S} [2]

Where S is our camera sensitivity.

And finally, we can relate our average luminance to our camera sensitivity with:

(3) \frac{N^2}{t} = \frac{L_{Avg}S}{K}

Where K is our calibration constant [1][5]. We can rearrange this question for S as:

(4) \frac{N^2K}{tL_{Avg}} = S

If we equate (1) and (2)

\frac{qt}{N^2}L_{MiddleGrey} = \frac{10}{S}

And substitute (4)

\frac{qt}{N^2}L_{MiddleGrey} = \frac{10tL_{Avg}}{N^2K}

Solving for L_{MiddleGrey} we get

\frac{qt}{N^2}L_{MiddleGrey} = \frac{10tL_{Avg}}{N^2K}

qL_{MiddleGrey} = \frac{10L_{Avg}}{K}

L_{MiddleGrey} = \frac{10L_{Avg}}{qK}

And using q=0.65 and K=12.5 [1]

(5) L_{MiddleGrey} = 1.23L_{Avg}

As a result, we can see that our middle grey luminance is equal to 1.23 times our average scene luminance.

Finally, we can use this relationship to derive our maximum luminance with:

\frac{\sqrt{2}}{H_{Max}} = \frac{0.18}{H_{MiddleGrey}}

\frac{H_{MiddleGrey}\sqrt{2}}{0.18} = H_{Max}

Replacing with (1)

\frac{\frac{qt}{N^2}L_{MiddleGrey}\sqrt{2}}{0.18} =  \frac{qt}{N^2}L_{Max}

\frac{L_{MiddleGrey}\sqrt{2}}{0.18} =  L_{Max}

7.8L_{MiddleGrey}=  L_{Max}

Substituting with (5) we get

7.8*1.23L_{Avg} = L_{Max}

9.6L_{Avg} = L_{Max}

And there you have it! We now have our maximum luminance from our average luminance.

Another approach to deriving the maximum luminance from average luminance can be seen with [1].

Following the steps outlined in the document we get:

H_{Max} = \frac{78}{S}

Which we then substitute H_{Max} with (1)

\frac{qt}{N^2}L_{Max} = \frac{78}{S}

Solving for L_{Max}

L_{Max} = \frac{78}{S}\frac{N^2}{qt}

We can substitute \frac{N^2}{t} with (3):

L_{Max} = \frac{78}{S}\frac{1}{q}\frac{L_{Avg}S}{K}

L_{Max} = 78\frac{1}{q}\frac{L_{Avg}}{K}

[1] assuming q=0.65 and K=12.5 we get:

L_{Max} = \frac{78}{0.65*12.5}L_{Avg}

L_{Max} = \frac{78}{0.65*12.5}L_{Avg}

L_{Max} = 9.6L_{Avg}

However a piece that gives me pause in this derivation is the use of:

H_{Max} = \frac{78}{S}

Where does that 78 come from?

The ISO standard dictates that H_{MiddleGrey}=\frac{10}{S}

Since H_{Max}\frac{0.18}{\sqrt{2}}= H_{MiddleGrey} with Saturation Based Sensitivity we can derive that:

H_{Max}\frac{0.18}{\sqrt{2}}=\frac{10}{S}

H_{Max}=\frac{10\sqrt{2}}{0.18S}

H_{Max}=\frac{10\sqrt{2}}{0.18S}

H_{Max}=\frac{78.6}{S}

Therefore the 78 results from the relationship between middle grey luminous exposure and maximum luminous luminous exposure set by Saturation Based Sensitivity.


The Conclusion

I find it particularly amusing how you can reach the same results from various directions in math. With this post complete, I feel far more comfortable dealing with exposure and hopefully this has provided some insights into the various formulas and values in play when dealing with exposure.

As a side note, when writing this post, I got particularly confused about the difference between H_{Max}, H_{MiddleGrey} and H_{Avg}. Originally believing that H_{MiddleGrey}=H_{Avg} which led to some very strange results.

If you believe that H_{MiddleGrey}=H_{Avg} you end up believing that L_{MiddleGrey}=L_{Avg}. And as a result, taking \frac{L_{MiddleGrey}\sqrt{2}}{0.18} = L_{Max} and turning it into \frac{L_{Avg}\sqrt{2}}{0.18} = L_{Max} which becomes 7.8L_{Avg}= L_{Max} Which completely disagrees with our conclusion that 9.6L_{Avg}= L_{Max}! I thought I was going mad…

Thankfully my coworker Bruno (@BruOps) pointed out my mistake to me. (Thanks Bruno! Also thanks to my coworker Thomas Hill for dealing with me rambling about exposure for a week.)

In the next post, I will likely be working through the derivation for various Normal Distribution Functions as I’ve had the pleasure of working through the mathematics of it all and I find it particularly interesting! I’d recommend reading https://www.reedbeta.com/blog/hows-the-ndf-really-defined/ as it provided the foundation I needed to derive those functions. (Really my next post will likely just be a rehash of that post just formulated differently and with some intuitions I gathered along the way… seriously, go read it!) Maybe we’ll use it as an opportunity to make up some fun NDFs. Who knows!

The References

[1] https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/course-notes-moving-frostbite-to-pbr-v2.pdf#page=86

[2] https://www.imatest.com/docs/sensitivity_ei/

[3] https://www.dpreview.com/forums/thread/4579986?page=2

[4] https://en.wikipedia.org/wiki/Film_speed#Saturation-based_speed

[5] http://www.yedlin.net/NerdyFilmTechStuff/ExposureEquationsAndMeterCalibration.html

Advertisement

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s