您的位置:首页 > 移动开发 > Unity3D

Unity3D图像后处理特效——Grayscale image effect

2012-09-19 06:30 375 查看
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.

所有图像特效如果无法在用户显卡上运行时将会自动被关闭。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: