High Dynamic Range Rendering高动态范围(HDR)渲染
In standardrendering, the red, green and blue values for a pixel are each represented by afraction in the range 0..1, where 0 represents zero intensity and 1 representsthe maximum intensity for the display device. While this is straightforward touse, it doesn’t accurately reflect the way that lighting works in a real lifescene. The human eye tends to adjust to local lighting conditions, so an objectthat looks white in a dimly lit room may in fact be less bright than an objectthat looks grey in full daylight. Additionally, the eye is more sensitive tobrightness differences at the low end of the range than at the high end.
在标准渲染,每像素的红、绿、蓝值表示0~1的范围比例,其中0表示零强度和1表示显示设备的最大强度。虽然这是直观使用,它并不能准确反映在真实的生活场景的照明。人眼倾向于以适应本地的照明条件,所以,一个物体在昏暗的房间里看起来是白色的,并不比在日光下灰色的物体亮。此外,眼睛在该范围看低处的亮度差异比在高处更敏感。
More convincingvisual effects can be achieved if the rendering is adapted to let the ranges ofpixel values more accurately reflect the light levels that would be present ina real scene. Although these values will ultimately need to be mapped back tothe range available on the display device, any intermediate calculations (suchas Unity’s image effects) will give more authentic results. Allowing theinternal representation of the graphics to use values outside the 0..1 range isthe essence ofHigh Dynamic Range (HDR) rendering.
更有说服力的视觉效果可以实现,如果让渲染适应像素值的范围更准确的反射灯光的等级,这将是一个真实的场景。虽然这些值将最终需要被映射回显示设备的可用范围,任何中间计算(如Unity的图像效果)将提供更真实的结果。允许使用内部的图像,0...1值外范围是高动态范围(HDR)渲染。
Working with HDR使用HDR
HDR is enabledseparately for each camera using a setting on the Camera component:-
HDR为每个相机组件单独启用设置:
When HDR is active, the scene is rendered into an HDR imagebuffer which can accommodate pixel values outside the 0..1 range. This bufferis then postprocessed using image effects such asHDR bloom. The tonemapping image effect is what converts theHDR image into the standard low dynamic range (LDR) image to be sent fordisplay. The conversion to LDR must be applied at some point in the imageeffect pipeline but it need not be the final step if LDR-only image effects areto be applied afterwards. For convenience, some image effects can automaticallyconvert to LDR after applying an HDR effect (see Scripting below).
当HDR激活,该场景被渲染成一个HDR图像缓冲区可容纳0..1范围以外的像素值。这个缓冲区然后被后期处理使用图像效果,如HDR bloom。色调映射tonemapping图像效果是转换HDR图像到标准的低动态范围(LDR)图像发送显示。转换到LDR必须在一些点应用图像效果管线,如果仅LDR图像效果在后来应用,但它不需要最后一步。为方便起见,一些图像效果能自动转换为 LDR之后应用HDR效果(请参见下面的脚本)。
Tonemapping is the process of mapping HDR values back intothe LDR range. There are many different techniques, and what is good for oneproject may not be the best for another. A variety of tonemapping image effectshave been included in Unity. To use them select Assets -> Import Package-> Image Effects (Pro Only) select the camera in the scene then selectComponent -> Image Effects ->ToneMapping a detailed description of thetonemapping types can be found in theimage effects documentation.
Tonemapping是HDR值反映射回到LDR范围的过程。有许多不同的技术,在这个项目是好的,未必在另外一个项目也是最好的。各种tonemapping图像特效已包含在Unity中。要使用他们,选择Assets -> Import Package -> Image Effects (Pro Only) ,选择在场景中的摄像机,然后选择Component -> Image Effects ->ToneMapping,关于tonemapping类型的详细描述,可以在图像特效文档找到image effects documentation.。
Anexceptionally bright scene rendered in HDR. Without tonemapping, most pixelsseem out of range.
在HDR渲染下异常明亮的场景。无光泽贴图,大多数像素似乎超出范围。
Thesame scene as above. But this time, the tonemapping effect is bringing mostintensities into a more plausible range. Note that adaptive tonemapping caneven blend between above and this image thus simulating the adaptive nature ofcapturing media (e.g. eyes, cameras).
如上一样的场景。但这次,tonemapping的效果用于把明亮的强度降低到更为合理的范围。注意:注意,自适应的tonemapping甚至可以在上面和这个图像之间混合,从而模拟自然的自适应性介质的捕获(例如,眼睛,相机)。
HDR Bloom and Glow
Using HDR allows for much more control in post processing.LDR bloom has an unfortunate side effect of blurring many areas of a scene evenif their pixel intensity is less than 1.0. By using HDR it is possible to onlybloom areas where the intensity is greater than one. This leads to a much moredesiarable outcome with only super bright elements of a scene bleeding intoneighboring pixels. The built in 'Bloom and Lens Flares' image effect now alsosupports 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 detaileddescription of the 'Bloom and Lens Flares' effect can be found in theimageeffects 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 LensFlare) (支持HDR和镜头光晕),详细描述 "Bloom and Lens Flares'"效应,可以查阅图像特效文档 image effects documentation。
The car window sun reflections in this scenehave intensity values far bigger than 1.0. Bloom can only pick up and glowthese parts if the camera is HDR enabled thus capturing these intensities.
在这一场景中,汽车窗口的反射强度比1.0大得多。如果相机是HDR,那么Bloom只能接收并发出这些部分,从而捕捉到这些强度。
Thecar window will remain without glow if the camera is not HDR enabled. Only wayto add glow is to lower the intensity threshold but then unwanted parts of theimage will start glowing as well.
如果相机没有启用HDR,汽车窗口将保持不发光。添加辉光的唯一方法是降低强度阈值,但随后图像中不需要的部分也会开始发光。
In forward rendering mode HDR is only supported if you havean image effect present. This is due to performance considerations. If you haveno image effect present then no tone mapping will exist and intensitytruncation will occur. In this situation the scene will be rendered directly tothe backbuffer where HDR is not supported.
正向渲染模式下,HDR仅支持在如果目前有一个图像特效的情况下。这是由于性能方面的考虑。如果你当前没有图像效果那么将不会发生色调映射和发生强度截断。在这种情况下,场景将直接渲染到不支持HDR的后备缓冲区。
In HDR mode the lighting buffer is also allocated as afloating point buffer. This reduces banding in the lighting buffer. HDR issupported in deferred rendering even if no image effects are present.
在HDR模式下,灯光prepass缓冲区也被分配成浮点缓冲区。这将减少照明缓冲区的波段。即使当前没有图像特效,在延迟渲染下支持HDR。
The ImageEffectTransformsToLDR attribute can be added to animage effect script to indicate that the target buffer should be in LDR insteadof HDR. Essentially, this means that a script can automatically convert to LDRafter applying its HDR image effect. See Writing ImageEffects for more details.
ImageEffectTransformsToLDR属性可以被添加到图像效果脚本来表示目标缓冲区应该是在LDR,而不是HDR的。基本上,这意味着一个脚本可以自动转换到LDR后应用HDR图像效果。更多细节请参见Writing Image Effects。
Seealso
HDR ColorPicker.