Unity3D圖像後處理特效——Grayscale image effect

Grayscale is a simple image effect that changes colors to grayscale by default. It can also use a Texture Ramp texture to remap luminance to arbitrary colors. 
灰度圖像特效是一種將原始顏色轉變成灰度的圖像特效。它可以使用一個Texture Ramp紋理來將亮度值重新映射到任意的顏色。

Like all image effects, Grayscale is available in Unity Pro only. Make sure to have the Pro Standard Assets installed. 
和其他圖像特效一樣,該特效只能在Unity Pro上進行使用,並且在使用之前必須安裝Pro Standard Assets。



Grayscale image effect applied to the scene
應用於場景的灰度圖像特效

Remapping colors        重新映射顏色

Grayscale can do a simple version of color correction, i.e. remap grayscale image into arbitrary colors. This can be used for effects like heat vision. 
灰度圖像特效是顏色校正特效的一個簡單版本,即,將灰度圖像映射到任意的顏色。這可以用來模擬熱源顯示效應。

The process of color remapping is very similar to ColorCorrection effect: 
顏色衝映射操作與顏色校正特效非常相似:

1.      Take a screenshot of a typical scene in your game. 
         在您的遊戲中對於場景進行截屏

2.      Open it in Photoshop and convert to grayscale. 
         在Photoshop中打開它,並將其轉變爲灰度圖

3.      Color correct it using the Image->Adjustments->Curves. 
         使用Image->Adjustments->Curves來進行顏色校正

4.      Save the .acv file file from the dialog using Save... 
         使用Save...來將其保存成.acv文件

5.      Open Pro Standard Assets->Image Based->color correction ramp.png in Photoshop 
        在Photoshop中打開Pro Standard Assets->Image Based->color correction ramp.png

6.      Now apply color correction to the ramp image: open Image->Adjustments->Curves again and load your saved .acv file 
         將顏色校正操作應用於漸變圖像上:再次打開Image->Adjustments->Curves,並導入您保存的.acv文件

7.      Select your camera in Unity and select Component->Image Effects->Grayscale to add the effect. Select your modified color ramp. 
         在Unity中選擇您的相機,並添加灰度圖像特效Component->Image Effects->Grayscale,同時選擇您的顏色漸變圖像。

8.      Hit Play to see the effect in action! 
         運行並查看效果

Details        技術細節
Color remapping works by remapping the original image luminance through the color ramp image (sized 256x1): 
顏色重映射操作是通過將原始圖像亮度映射到顏色漸變圖像(256x1)上:

       result color = pixel's color in the ramp image at (OriginalLuminance + RampOffset) index. For example, to invert the colors in the image 
       you only need to flip the original color ramp horizontally (so that it goes from white to black instead of from black to white): 
       結果顏色=漸變圖像上索引爲(OriginalLuminance + RampOffset)的像素顏色。比如,要翻轉圖片上的顏色,您只需水平翻轉原始的漸變圖像即可(這樣它才能從白色到從黑色到白色而不是黑色)。


Grayscale applied to the scene with color ramp that goes from white to black.

應用於場景的灰度圖像特效效果,顏色漸變圖像是從白到黑

A more complex version of color remapping that does arbitrary color correction can be achieved with ColorCorrection image effect. 
關於顏色重映射的更加複雜的版本可見顏色校正圖像特效。

Hardware support        硬件支持
This effect requires a graphics card with pixel shaders (2.0) or OpenGL ES 2.0. PC: NVIDIA cards since 2003 (GeForce FX), AMD cards since 2004 (Radeon 9500), Intel cards since 2005 (GMA 900); Mobile: OpenGL ES 2.0; Consoles: Xbox 360, PS3. 
這個特效需要顯卡擁有像素着色器(2.0)或者OpenGL ES 2.0。臺式機:2003年以後的NVIDIA顯卡(GeForce FX),2004年以後的AMD顯卡(Radeon 9500),2005年以後的Intel卡(GMA 900);移動設備:OpenGL ES 2.0;控制檯: Xbox 360、 PS3。

All image effects automatically disable themselves when they can not run on end-users graphics card. 
所有圖像特效如果無法在用戶顯卡上運行時將會自動被關閉。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章