1. 程式人生 > >Unity Lighting - High Dynamic Range (HDR) 高動態範圍(五)

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 AssetsTonemapping Image EffectAssets>Import Package>Effects)新增到相機。通過此指令碼,您可以控制相機記錄的非常明亮的色彩強度如何轉換為可以顯示的顏色。

More information on Tonemapping can be found here.更多關於Tonemapping的資訊可以在這裡找到。