 Now to the second part. It's quite different, so it's tone mapping. This is concerned in our so before we had optimization for the light simulation. Now we will look at the very end of our rendering pipeline. So the issue of showing the image output on a display. Because the problem is that a light simulation outputs radians. So it's the how much light travels along one direction when it comes from a small surface patch. So you collect radians with your camera, recorded, but somehow your display expects RGB values. So the radians can carry some color information. So you could, for example, trace the R, the G, the B value, Genuo independently. You can do something with more fidelity like spectral ray tracing. So your trace raised that where not only radians is carried along the ray, but spectral radians. So radians of a certain wavelength of the light. This, for example, you can see this effect in Prisons where you split white light into rainbow colors. So if you do not perform spectral ray tracing there and just assume we have white radians, then you cannot simulate this effect. Because then the refraction, so the ray geometry changes with the wavelength that's associated to it. So your reflection angles get different and this causes the split into the rainbow colors. So, but in some way you have radians as output. So to show them on displays or to bring them, you need to convert your images somehow from radians to RGB. And there is an inherent problem with that because radians of light simulation have a huge range because they try to simulate real world physics. And in real world, you have a huge difference between dark and bright. So for example, if you take the ratio between the surface at say ground level in the Earth atmosphere that is either illuminated by the sun or the moon, the difference is a factor of 800,000. And then imagine that the patch on the ground is either white or black. This causes another difference in the reflected radians quantities of approximately a factor 100. So if you want to do say a general light simulation and you can expect that illumination by a sun and moon should be in there, white and black surfaces should also be in there. You have to somehow cope with a ratio between the darkest and the brightest values of 80 million. So is it relevant to do that? So can people even see the difference between that? And yes, they can. So since these are highly relevant features of our world to differentiate dark from bright, especially under very bright and dark conditions. So imagine a caveman in the woods at night. It will be very good to see small contrast differences that could indicate predators. So there was a evolutionary forcing to develop a visual system that also can take advantage of this huge dynamic range of radians values. So for example, how does this build up? So for the receptors in our eyes, they have chemical bleaching when they are hit by light particles. So this can be regulated biochemically to enable adaptation in a range of two orders of magnitude. So just by regulating the biochemical properties of photoreceptors, you can adapt the eye to a different in dark and bright of 100. The pupil size gives you another order of magnitude, so a factor of 10, and the neural adaptation is more or less the single processing. So what to do actually with the changing signal because your receptors get bleached. So the dynamic range of human vision is approximately 100 million. So that means that we can perceive, in fact, the dynamic range of realistic conditions in our atmosphere. But then you have, so the output of a light simulation, if it takes this into account, can be, I can have a difference of 80 million, a factor of 80 million between dark and bright, and then you want to show this on the display. So the technology for a standard display gives you a dark to bright ratio of approximately 1000. And if you use 8-bit encoding of your values, then you only have 265 values for 8-bit channels. That means that somehow our technology is immensely inadequate to show realistic scenarios. In some way, this is also good because you get not blinded by your display, but we have to somehow account for that. So just taking the radians output and converting it to images will carry some problems with it. Yeah. But why 8-bit image files for visually witnessed files are 24 bits of information? But usually you split them into the different color values. So you have 8 bits for R, 8 bits for G, 8 bits for B. And somehow imagine that this gives you how much red light is at this pixel. And yeah, you go to 266. Of course, for the whole color gamut, you have more values, but if you just look at the dark bright ratio of a single color, this is approximately what you have. So now tone mapping is the methods that was developed to convert this problem. So the output of a light simulation, as already said, high dynamic range because of the real world dynamic range of brightness values. And display devices usually have a low dynamic range. So what you need to do is to compress the range of our output somehow. And this is referred to as either tone mapping or tone reproduction. These are the names that you find in literature. So there are two sub-issues here. One is range compression. So how to convert high dynamic range luminance to low dynamic range luminance. This is the content of this lecture. And then you still have luminances, but usually there are standardized color spaces in which images are stored. So you don't store your own whole-brune formats, which take certain wavelength and then gives the luminance values for those. But there are standardized ways to do that. And this is covered in a different lecture about color. You see the lecture number here. So I refer you to this lecture if you want to know more about color. And here now I only explain range compression to some extent. So now a graphic example. So here we have a bright, a single bright light source with no ambient light in the scene. That means that all contrast comes only from this one light source via global illumination. So if you take, if you would photograph the scene and take a short exposure, this is what you get. So all the dimly illuminated parts completely disappear in black. And but you see details in previously two bright scenes. So that led to overexposure of your camera. So for example here, you now see the outline, so the silhouette of the bulb, for example. A very long exposure leads to overexposure of most of the image. So you do not see any detail anymore close to the lamp or at directly illuminated surfaces. But what you see is that previously dimly illuminated objects in the background now are well perceivable. So this is what you get if you take only small parts of your dynamic range and map those to an image. And what could you do to combine all this information into one image? So the most trivial thing you can imagine is I just divide by the maximum of the scene. This gives me a nice luminance values from 0 to 1. And this I can map to whatever range I want. The problem with this is that usually the maximum is not indicative of the whole scene. The maximum is usually extremely bright. So when you're divide by the maximum, the only thing you see is a single reflection in the close to the light bulb. If you clamp it, so let's say I have a range of luminances that I'm interested in, everything below is clamped by a 0. Everything above my maximum that I decide to have is completely white. This is exactly the problem that becomes obvious with high dynamic range that parts are undexposed or the parts are always exposed. So clamping also doesn't get you something. You have to take the whole range. You cannot just ignore certain parts. So one approach that gives you nice results is exponential mapping. There, you assume exponential distribution in your luminance values and then rescale this exponential function into a linear one. That means that very bright values get scaled down. Low values get scaled up. But you account for the very bright spots. So these are the things that get scaled the most. So the bright values at the bar get some reasonable white, but they do not dominate the whole scene. A more sophisticated approach is the Reinhardt tool map developed by Reinhardt. And this is the one example that we present in this lecture. As you can imagine, there are many tool map. So everyone tried some approach that works very well for a certain subset of scenes. Some methods were optimized for parallel hardware or for certain hardware architectures to give more speed there. Some presented rough approximation that work in real time. So there is already a quite wide bunch of tool map to choose from. And Reinhardt tool map is one of the most common. So if you look into some, at an open source of commercial rendering software, this is usually one of the things that is implemented. So and there is also some additional information that put this into context. There is some approach in digital photography to take multiple exposure images. So to combine exposures of the same scene that are taken with different exposure times into one image. So this is called hydonomic range photography. And usually they use similar methodologies. So the Reinhardt tool map can also be used to combine or for HDR photography. But if you put HDR photography into Google, you usually end up with images like that. And this is not what tool mapping is about. Tool mapping is a perceptually and physically validated approach that gives you realistic impressions of the scene and is not an artistic effect. So it's not that you take tone mapping, look at the image and say, I would like to have it to have more contrast in there. And then you change your tone map. I mean, this is not it didn't stand that use and the community of HDR photography to a large extent over uses this capability of the system. For example, this photograph here is a completely botched implementation or use of HDR range compression. For example, things that you see that are not correct. The haloes around the balloons. So suddenly, why the sky is brighter around the silhouettes of the balloons? This is an effect that is present in the visual system to some extent, but not to this extent. So some people think that this is nice HDR photography, but this is just wrong, simply a stat. If you like that your images look like that, then this is an artist's decision, not tone mapping. This is just contrast enhancement, you can call it like that. Also, the colors in this image get screwed up because they are now oversaturated. But this is just a warning. The tone mapping that you encounter for light simulations should not look like that because then you have a run your application. So if you would take this photo with this one exposure? I mean, this is a combination of different exposure. But also some mind-blowing. It's not just a combination of different exposure, but also some... No, it is a combination of different exposures and it's taken with a tone mapping approach. You have to do the combination somehow. As said before, you can add a device by the maximum and combine them, clamping. But usually the tone mapping give you a more realistic result, and for example, why is it obvious that here already multiple exposures were combined? Because in the very left of the left balloon, you see that you still see some kind of detail in the wood in behind. But at the same time, you can all less directly look into the sun without it having blurred half the screen. So that means that already a huge dynamic range was compressed here. But it should not look like that. It should look like that if it's done correctly. And this would be the correct application for this photograph. So it looks somehow realistic. It doesn't over-saturate the colors. It only has a very light halo around the silhouettes, which is also an effect that's present in the visual system. So this is what you should aim for. So now about tone mapping itself. There are two large different classes. So one are the global tone mapas and the other are the local. So the global tone mapas use a mapping function that converts radians at a certain pixel to say RGB value if you select this color space. And this mapping function is uniform. What I mean here is not that it's uniform. It produces the uniform output value. So you don't get an image with a single color value. But the function itself just takes as input the radians at a certain pixel and outputs RGB value. And this function is then used for all pixels of the image. More complex methodologies are local tone mapas, which not only take a single pixel into account, but also its neighbor's. And this is perceptually motivated because as you have seen before, this contrast or brightness adaptation of your eyes. In the photo receptors, for example, this is done locally. So a single photo receptor adapts to different brightnesses. So that means that you tone mapping in the human eye is a local behavior. But there are there are reasons to employ both of them. So the global tone mapas, they are fast because they have a single mapping function. So you take you can execute this function parallel on each pixel. So this makes it perfectly usable for GPU approaches, for example. But you'll incur some loss of detail because you cannot locally look as if this is already a dark patch of my scene. So I can enhance the contrast more there. Or is it at a dark bright boundary where I do not do it that much. And the local tone mapas allow this. So they allow a local contrast enhancement, but they are slow because you not only have to say, look at the pixel, but also its neighborhood. The neighborhood grows quadratically if you enlarge it. So I'm there you will incur a different complexity in your problem.