In standard rendering, the red, green and blue values for a pixel are each represented by a fraction in the range 0..1, where 0 represents zero intensity and 1 represents the maximum intensity for the display device. While this is straightforward to use, it doesn't accurately reflect the way that lighting works in a real life scene. The human eye tends to adjust to local lighting conditions, so an object that looks white in a dimly lit room may in fact be less bright than an object that looks grey in full daylight. Additionally, the eye is more sensitive to brightness differences at the low end of the range than at the high end.
在标准渲染,每像素的红、绿、蓝值表示0~1的范围比例,其中0表示零强度和1表示显示设备的最大强度。虽然这是直观使用,它并不能准确反映在真实的生活场景的照明。人眼倾向于以适应本地的照明条件,所以,一个物体在昏暗的房间里看起来是白色的,并不比在日光下灰色的物体亮。此外,眼睛在该范围看低处的亮度差异比在高处更敏感。
More convincing visual effects can be achieved if the rendering is adapted to let the ranges of pixel values more accurately reflect the light levels that would be present in a real scene. Although these values will ultimately need to be mapped back to the range available on the display device, any intermediate calculations (such as Unity's image effects) will give more authentic results. Allowing the internal representation of the graphics to use values outside the 0..1 range is the essence of High Dynamic Range (HDR) rendering.
更有说服力的视觉效果可以实现,如果让渲染适应像素值的范围更准确的反射灯光的等级,这将是一个真实的场景。虽然这些值将最终需要被映射回显示设备的可用范围,任何中间计算(如Unity的图像效果)将提供更真实的结果。允许使用内部的图像,0...1值外范围是高动态范围(HDR)渲染。
Working with HDR 使用HDR
HDR is enabled separately for each camera using a setting on the Camera component:-
HDR为每个相机组件单独启用设置:
When HDR is active, the scene is rendered into an HDR image buffer which can accommodate pixel values outside the 0..1 range. This buffer is then postprocessed using image effects such as HDR bloom. The tonemapping image effect is what converts the HDR image into the standard low dynamic range (LDR) image to be sent for display. The conversion to LDR must be applied at some point in the image effect pipeline but it need not be the final step if LDR-only image effects are to be applied afterwards. For convenience, some image effects can automatically convert to LDR after applying an HDR effect (see Scripting below).
当HDR激活,该场景被渲染成一个HDR图像缓冲区可容纳0..1范围以外的像素值。这个缓冲区然后被后期处理使用图像效果,如HDR bloom。色调映射tonemapping图像效果是转换HDR图像到标准的低动态范围(LDR)图像发送显示。转换到LDR必须在一些点应用图像效果管线,如果仅LDR图像效果在后来应用,但它不需要最后一步。为方便起见,一些图像效果能自动转换为 LDR之后应用HDR效果(请参见下面的脚本)。
Tonemapping 色调映射
Tonemapping is the process of mapping HDR values back into the LDR range. There are many different techniques, and what is good for one project may not be the best for another. A variety of tonemapping image effects have been included in Unity. To use them select Assets -> Import Package -> Image Effects (Pro Only) select the camera in the scene then select Component -> Image Effects ->ToneMapping a detailed description of the tonemapping types can be found in the image effects documentation.
Tonemapping是HDR值反映射回到LDR范围的过程。有许多不同的技术,在这个项目是好的,未必在另外一个项目也是最好的。各种tonemapping图像特效已包含在Unity中。要使用他们,选择Assets -> Import Package -> Image Effects (Pro Only) ,选择在场景中的摄像机,然后选择Component -> Image Effects ->ToneMapping,关于tonemapping类型的详细描述,可以在图像特效文档找到image effects documentation.。
An exceptionally bright seen rendered in HDR. Tonemapping is used to bring the bright intensities back into the displayable range.
在HDR下渲染看到格外明亮。 tonemapping用于把明亮的强度降低到可显示的范围。
HDR Bloom
Using HDR allows for much more control in post processing. LDR bloom has an unfortunate side effect of blurring many areas of a scene even if their pixel intensity is less than 1.0. By using HDR it is possible to only bloom areas where the intensity is greater than one. This leads to a much more desiarable outcome with only super bright elements of a scene bleeding into neighboring pixels. The built in 'Bloom and Lens Flares' image effect now also supports HDR. To attach it to a camera select Assets -> Import Package -> Image Effects (Pro Only) select the camera in the scene then select Component -> Image Effects ->Bloom (Supports HDR and Lens Flare) a detailed description of the 'Bloom and Lens Flares' effect can be found in the image effects documentation.
使用HDR,允许更多的后处理控制。LDR bloom有些副作用,场景的许多区域变得模糊,即使他们的像素强度小于1.0。通过使用HDR,只bloom像素强度大于1的区域。这将导致一个场景中超高亮度元素渗色到邻近的像素得到更理想的结果。内置的"Bloom and Lens Flares'"的图像特效现在也支持HDR。选择Assets -> Import Package -> Image Effects (Pro Only) 把它关联到摄相机,选择在场景中的摄像机,然后选择Component -> Image Effects ->Bloom (Supports HDR and Lens Flare) (支持HDR和镜头光晕),详细描述 "Bloom and Lens Flares'"效应,可以查阅图像特效文档 image effects documentation。
An exceptionally bright scene where bloom has been applied to intensities greater than 1.0. The bloomed image has also been tonemapped back into the displayable range.
一个格外明亮的场景,像素强度>1.0的地方已经使用bloom。Bloom处理后的图像也进行tonemapped,变到可显示的范围。
Advantages of HDR ( HDR的优势)
- Colors not being lost in high intensity areas 颜色在高强度区域不会丢失
- Better bloom support 更好支持bloom
- Reduction of banding in low frequency lighting areas 减少低频照明区域的波段
Disadvantages of HDR ( HDR的缺点)
- Uses Floating Point buffers (rendering is slower and requires more VRAM)
使用浮点缓冲区(渲染很慢并且需要更多显存) - Not supported on all hardware
不是所有的硬件都支持
Usage notes 使用说明
Forward Rendering 正向渲染
In forward rendering mode HDR is only supported if you have an image effect present. This is due to performance considerations. If you have no image effect present then no tone mapping will exist and intensity truncation will occur. In this situation the scene will be rendered directly to the backbuffer where HDR is not supported.
正向渲染模式下,HDR仅支持在如果目前有一个图像特效的情况下。这是由于性能方面的考虑。如果你当前没有图像效果那么将不会发生色调映射和发生强度截断。在这种情况下,场景将直接渲染到不支持HDR的后备缓冲区。
Deferred Rendering 延迟渲染
In HDR mode the light prepass buffer is also allocated as a floating point buffer. This reduces banding in the lighting buffer. HDR is supported in deferred rendering even if no image effects are present.
在HDR模式下,灯光prepass缓冲区也被分配成浮点缓冲区。这将减少照明缓冲区的波段。即使当前没有图像特效,在延迟渲染下支持HDR。
Scripting 脚本
The ImageEffectTransformsToLDR attribute can be added to an image effect script to indicate that the target buffer should be in LDR instead of HDR. Essentially, this means that a script can automatically convert to LDR after applying its HDR image effect.
ImageEffectTransformsToLDR属性可以被添加到图像效果脚本来表示目标缓冲区应该是在LDR,而不是HDR的。基本上,这意味着一个脚本可以自动转换到LDR后应用HDR图像效果。