90 4 Camera- <strong>and</strong> Exposure Effects4.1.2 The “Photographic” Tone Mapper4.1.2.1 mia exposure photographicThe photographic tonemapper converts actual pixel luminances (in c<strong>and</strong>ela per square meter)into image pixels as seen by a camera, applying camera-related parmeters (like f-stops <strong>and</strong>shutter times) for the exposure, as well as applying tonemapping that emulates film- <strong>and</strong>camera-like effects.It has two basic modes:• “Photographic” - in which it assumes input values are (or can be converted to) c<strong>and</strong>elaper square meter.• “Arbitrary” - in which scene pixels are not considered to be in any particular physicalunit, but are simply scaled by a factor to fit in the display range of the screen.If the film iso parameter is nonzero, the “‘Photographic” mode is used, <strong>and</strong> if it is zero, the“Arbitrary” mode is chosen.declare shader "mia_exposure_photographic" (scalar "cm2_factor" default 1.0,color "whitepoint" default 1 1 1,scalar "film_iso" default 100,scalar "camera_shutter" default 100.0,scalar "f_number" default 16.0,scalar "vignetting" default 1.0,scalar "burn_highlights" default 0.0,scalar "crush_blacks" default 0.25,scalar "saturation" default 1.0,scalar "gamma" default 2.2,integer "side_channel_mode" default 0,string "side_channel",color texture "preview",boolean "use_preview")version 4apply lens, outputend declareIn “Photographic mode” (nonzero film iso) cm2 factor is the conversion factor betweenpixel values <strong>and</strong> c<strong>and</strong>ela per square meter. This is discussed more in detail below.
4.1 Tone Mapping 91In “Arbitrary” mode, cm2 factor is simply the multiplier applied to scale rendered pixelvalues to screen pixels. This is analogous to the gain parameter of mia exposure simple.whitepoint is a color that will be mapped to “white” on output, i.e. an incoming color ofthis hue/saturation will be mapped to g<strong>ray</strong>scale, but its intensity will remain unchanged.film iso should be the ISO number of the film, also known as “film speed”. As mentionedabove, if this is zero, the “Arbitrary” mode is enabled, <strong>and</strong> all color scaling is then strictlydefined by the value of cm2 factor.camera shutter is the camera shutter time expressed as fractional seconds, i.e. the value100 means a camera shutter of 1/100. This value has no effect in “Arbitrary” mode.f number is the fractional aperture number, i.e. 11 means aperture “f/11”. Aperture numberson cameras go in specific st<strong>and</strong>ard series, i.e. “f/8”, “f/11”, “f/16”, “f/22” etc. Each of theseare refered to as a “stop” (from the fact that aperture rings on real lenses tend to have physical“clicks” for these values) <strong>and</strong> each such “stop” represents halving the amount of light hittingthe film per increased stop 2 . It is important to note that this shader doesn’t count “stops”,but actually wants the f-number for that stop. This value has no effect in “Arbitrary” mode.In a real camera the angle with which the light hits the film impacts the exposure, causingthe image to go darker around the edges. The vignetting parameter simulates this. When0.0, it is off, <strong>and</strong> higher values cause stronger <strong>and</strong> stronger darkening around the edges. Notethat this effect is based on the cosine of the angle with which the light <strong>ray</strong> would hit the filmplane, <strong>and</strong> is hence affected by the field-of-view of the camera, <strong>and</strong> will not work at all fororthographic renderings. A good default is 3.0, which is similar to what a compact camerawould generate 3 .The parameters burn highlights <strong>and</strong> crush blacks guide the actual “tone mapping” of theimage, i.e. exactly how the high dynamic range imagery is adapted to fit into the black-towhiterange of a display device.If burn highlights is 1 <strong>and</strong> crush blacks is zero, the transfer is linear, i.e.behaves like a simple linear intensity scaler only.the shaderburn highlights can be considered the parameter defining how much “over exposure” isallowed. As it is decreased from 1 towards 0, high intensities will be more <strong>and</strong> more“compressed” to lower intensities. When it is 0, the compression curve is asymptotic, i.e.an infinite input value maps to white output value, i.e. over-exposure is no longer possible.A good default value is 0.5.When the upper part of the dynamic range becomes compressed it naturally loses some ofit’s former contrast, <strong>and</strong> one often desire to regain some “punch” in the image by using thecrush blacks parameter. When 0, the lower intensity range is linear, but when raised towards2 Sometimes the f-number can be found labeled “f-stop”. Since this is ambiguous, we have chosen the termf-number for clarity.3 Technically, the pixel intensity is multiplied by the cosine of the angle of the <strong>ray</strong> to the film plane raisedto the power of the vignetting parameter.