Unity Lighting - High Dynamic Range (HDR) 高动态范围(五)
High Dynamic Range (HDR)
高动态范围
As well as Color Space, the ‘dynamic range’ of your camera needs to be configured. Essentially, this defines how extremely bright or dark colors are captured by scene cameras. HDR can be enabled from the camera component in the Inspector by using the HDR checkbox. Note that HDR is unsupported by some mobile hardware. It is also not supported in Forward Rendering when using techniques such as multi-sample anti-aliasing (MSAA).
和Color Space一样,需要配置相机的“动态范围”。从本质上讲,它定义了场景摄像机捕捉极其明亮或深色的方式。通过使用HDR复选框,Inspector中的相机组件可以启用HDR。请注意,某些移动硬件不支持HDR。在使用诸如多重抗锯齿(MSAA)等技术时,它在正向渲染中也不受支持。
HDR is best used in combination with Linear Color Space in order to preserve accuracy when handling very bright colors.
HDR最好与线性色彩空间结合使用,以便在处理非常明亮的色彩时保持准确性。
By default, cameras in Unity use a Low Dynamic Range (LDR). Colors are stored using 8-bits per channel - red, green and blue. 8-bits refers to the ‘precision’ and means that color data is stored with 8 values of either 1 or 0, giving 256 possible unique combinations for each color channel. 256 x 256 x 256 colors per channel means that by storing values using 8-bits we are able to uniquely reference over 16 million color variations ranging in intensity from black to white.
默认情况下,Unity中的摄像机使用低动态范围(LDR)。颜色使用每通道8位存储 - 红色,绿色和蓝色。 8位是指“精度”,意味着颜色数据存储8个值为1或0,为每个颜色通道提供256种可能的独特组合。每通道256 x 256 x 256色意味着通过使用8位存储值,我们能够唯一参照超过1600万种颜色变化,亮度范围从黑色到白色。
In reality, colors in the real world extend far outside this 16 million color range. There are infinite permutations of color possibilities, and brightness goes beyond what our eyes can even see. Similarly Unity is capable of handling extremely bright lights which produce colors beyond that which can be displayed on an LDR device such as your computer screen. However, despite this potential limitation in the output device, these extreme light values still remain useful to us in a number of applications.
事实上,现实世界中的颜色远远超出了1600万色的范围。有无限的颜色可能性,亮度超出了我们的眼睛甚至可以看到的。同样,Unity能够处理极亮的灯光,这种灯光所产生的颜色超出了可以在电脑屏幕等LDR设备上显示的颜色。然而,尽管输出设备存在这种潜在的限制,但这些极端光线值仍然在许多应用中对我们有用。
By enabling HDR on your scene camera, colors will be stored with much greater precision (using the floating point representation). Many more unique colors over a much brighter range of luminance can be handled.
通过在场景摄像机上启用HDR,颜色将以更高的精度存储(使用浮点表示法)。可以处理更多亮度范围更多的独特颜色。
HDR enables us to preserve the great differences in brightness between, say, outdoor lighting in our scenes and shaded areas. We can also create effects like ‘blooms’ or glows by applying effects to these bright colors in your scene. Special effects like these can add realism to particles or other visible light sources. However, these extreme color values also need to be handled somehow to prevent them being ‘clamped’ to white.
HDR使我们能够保持我们场景中的室外照明和阴影区域之间的亮度差异。我们还可以通过对场景中的这些鲜艳颜色应用效果来创建效果,如“blooms”或发光效果。像这些特殊效果可以增加粒子或其他可见光源的真实感。然而,这些极端的颜色值也需要以某种方式处理,以防止它们被“钳制”成白色。
Tonemapping 色调映射
Using the analogy of photography, if we were to photograph our scene using different exposure settings, then we could start to see these extreme color details which otherwise might have been lost. Light tones in the brightest areas of the image which have been lost to white can be recovered, or dark tones lost to black. This is analogous to ‘tonemapping’ in computer graphics, where we take colors outside of the range reproducible by our target device (computer screen, for example) and shift them mathematically into a range which can be reproduced. The resulting output still makes sense perceptually, because colors remain relative to one another. They are correct in context.
使用摄影的类比,如果我们使用不同的曝光设置来拍摄我们的场景,那么我们可以开始看到这些可能会丢失的极端色彩细节。可以恢复图像中亮度最差的白色区域的浅色调,也可以恢复黑色的黑色。这与计算机图形学中的“色调映射”类似,我们将目标设备(例如计算机屏幕)可再现的范围之外的颜色带入其中,并将它们以数学方式转换为可复制的范围。由此产生的输出仍然是有意义的,因为颜色相对于彼此保持不变。他们在上下文中是正确的。
When using HDR cameras, the Tonemapping Image Effect from Standard Assets (Assets>Import Package>Effects) must be added to the camera. This script provides you control over how very bright color intensities recorded by your camera are converted into colors which can be displayed.
使用HDR相机时,必须将Standard Assets的Tonemapping Image Effect(Assets>Import Package>Effects)添加到相机。通过此脚本,您可以控制相机记录的非常明亮的色彩强度如何转换为可以显示的颜色。
More information on Tonemapping can be found here.更多关于Tonemapping的信息可以在这里找到。