在标准渲染中,像素的红色、绿色和蓝色值均由 0 到 1 范围内的分数表示,其中 0 表示零强度,1 表示显示设备的最大强度。虽然这很容易使用,但它并不能准确反映在现实生活场景中光照的运作方式。人眼倾向于适应局部光照条件,因此在光线昏暗的房间中看起来是白色的物体实际上可能还不如在强烈日光下看起来是灰色的物体明亮。此外,眼睛对昏暗范围的亮度差异比对明朗范围的亮度差异更敏感。
如果能调整渲染使像素值的范围来更准确地反映其在真实场景中的光照情况,则可以实现更真实的视觉效果。虽然这些值最终需要映射回显示设备上的可用范围,但任何中间计算(例如 Unity 的图像效果)都将提供更真实的结果。高动态范围 (HDR) 渲染的精髓是允许图形的内部表示使用 0 到 1 范围之外的值。
应使用摄像机组件上的设置为每个摄像机单独启用 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 used by post-processing effects such as the Bloom effect in the Post-processing stack. The HDR image is then converted into the standard low dynamic range (LDR) image to be sent for display. This is usually done via Tonemapping, part of the Color Grading pipeline. The conversion to LDR must be applied at some point in the post-process pipeline but it need not be the final step if LDR-only post-processing effects are to be applied afterwards. For convenience, some post-processing effects can automatically convert to LDR after applying an HDR effect (see Scripting below).
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 techniques have been included in the Post-processing stack. To use them you can download the Post-processing stack from the Asset Store. A detailed description of the tonemapping types can be found in the Color Grading documentation.
在前向渲染模式下,仅当您具有后期处理效果时才支持 HDR。这是出于性能考虑的原因。如果您没有后期处理效果,则不存在色调映射,并且将发生强度截断。在这种情况下,场景将直接渲染到不支持 HDR 的后备缓冲区。
在 HDR 模式下,光照缓冲区也被分配为浮点缓冲区。这样可减少光照缓冲区中的条带。即使没有后期处理效果,延迟渲染也支持 HDR。
The ImageEffectTransformsToLDR attribute can be added to a post-processing 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 post-processing effect. See Writing Custom Effects in the Post Processing package for more details.