颜色校正
2016-04-28 12:04
393 查看
转自 http://blog.csdn.net/cnjet/article/details/40582315
Introduce
Color correction is general term(refer to wiki), in video game, it's also called 'color grading'.
Color grading is the process of altering and enhancing the color of a motion picture, video image, or still image either electronically, photo-chemically or digitally. ---- From wiki page
In theory, it's done by mapping a color to another color. Gamma correction is most famous color correction effect. It will transform RGB color to sRGB color with power(2.2) operation. Most of the time, this kind of mapping will include many complex operations.
To accelerate real-time performance, most of game will use a 3D lookup table to realize color grading. This 3D lookup texture should be with very small size and usually offline created by artist outside of game engine by 3rd party software(such as Photoshop).
Also, it can be generated dynamically.
Most of photo process and video process software support color correction in some kind of way.
In general, there are two solutions for adjusting color grading:
[b]1. A curve can be modified by some key points:[/b]
Color Curve in GIMP
Very powerful and more flexible to control. But it's hard to understand for artist. some parameters based curve should be applied such as bezier curve.
[b]2. Some predefined effect with parameters:[/b]
Brightness and Contrast in GIMP
More easy to understand.So, most of software will support it.
There's many kinds of color correction effect exist. Different software will support different subset of them.
Brightness
Make whole scene more bright or more dark.
Contrast
Make whole scene have more contrast, dark more dark, bright more bright.With negative value, it will reduce the effect.
Hue
Change color hue.
Saturation
Change color saturation.
Exposure
Control the exposure of image.
Color balance
Control the color balance of image.
Gamma
Normally, convert from RGB to sRGB.
...
When combining different effects together, three different solutions exist:
1. Each effect is treated as one node with parameters. Then all effect nodes will applied one by one according the order in the sequence.
2. Some effects are combined into small groups. A static order of the effects are used in the group. Several small group will be applied one by one.
3. Combine all supported effects into one group. The group can be applied more than once.
Most of software also support only affect these effect on separate color channel(R, G, B, H, S, V, L). Some of effect can only affect shadows(such as [0,0.2]), midtones(such as (0.2,0.7]), highlights(such as (0.7,1.0]). Different software have different
subset of color correction effects. Even same color correction effect will be implemented by different method(mathematical function or curve).
As previous description about Lynx color correction feature and the research result of different software. Following is the design:
1. A new computer shader will be used to generate 3D LUT texture at runtime; It should be executed every frame or only some special frame according to performance requirement;
2. The 3D LUT texture should be small size to reduce the texture fetching cost on GPU; At same time keeping good visual quality; Similar with Trials Fusion, it's 32x32x16.
3. To keep high performance and simplify the usage, all support color correction features are combined into one shader with static order:
Contrast
Hue, Saturation and Exposure
Brightness
Color balance
Gamma
4. Different color correction effect has some parameter to control result. They are all exposed in shader constant buffer, the correct values are need to calculated in CPU side.
Detail implementation refer to HDR demo.
There are many color correction effects for different purpose, current implementation only realize basic color correction effect. Some other effect can be added later according to requirement.
Contrast
<new color> = <old color> + <contrast> * (<old color> - 0.5)
Hue, Saturation and Exposure
All these operation are done in HSL color space, luminace value is used to simulator exposure.
<new color> = convertHSLToRGB( convertRGBToHSL(<old color>) * <hue, saturation, exposure> )
Brightness
<new color> = <old color> + <constant>
Color balance
<new color> = <old color> * <color balance(r,g,b)>
Gamma
<new color> = pow( <old color>, 1/gamma)
Reference:
Color correction on Wiki: http://en.wikipedia.org/wiki/Color_correction
Color grading on Wiki: http://en.wikipedia.org/wiki/Color_grading
Using Lookup Tables to Accelerate Color Transformations: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html
Brightness, Constrast, Saturation, and Sharpness: http://www.steves-digicams.com/knowledge-center/brightness-contrast-saturation-and-sharpness.html
List of color space and their uses: http://en.wikipedia.org/wiki/List_of_color_spaces_and_their_uses
Unreal3 HSV&RGB conversion function: http://wiki.beyondunreal.com/HSV-RGB_Conversion
Unreal Legacy:Colors: http://wiki.beyondunreal.com/Legacy:Colors
NVIDIA shader library(color space operation): http://developer.download.nvidia.com/shaderlibrary/webpages/hlsl_shaders.html
Optimized RGB to HSL/HSV and HSL/HSV to RGB: http://www.chilliant.com/rgb2hsv.html
Color grading in blender: http://wiki.blender.org/index.php/Doc:2.6/Manual/Composite_Nodes/Types/Color
Enhancing Photographs in Gimp: http://docs.gimp.org/en/gimp-imaging-photos.html
CLUT: http://www.quelsolaar.com/technology/clut.html
Introduce
Color correction is general term(refer to wiki), in video game, it's also called 'color grading'.
Color grading is the process of altering and enhancing the color of a motion picture, video image, or still image either electronically, photo-chemically or digitally. ---- From wiki page
In theory, it's done by mapping a color to another color. Gamma correction is most famous color correction effect. It will transform RGB color to sRGB color with power(2.2) operation. Most of the time, this kind of mapping will include many complex operations.
To accelerate real-time performance, most of game will use a 3D lookup table to realize color grading. This 3D lookup texture should be with very small size and usually offline created by artist outside of game engine by 3rd party software(such as Photoshop).
Also, it can be generated dynamically.
Ideas
Most of photo process and video process software support color correction in some kind of way. In general, there are two solutions for adjusting color grading:
[b]1. A curve can be modified by some key points:[/b]
Color Curve in GIMP
Very powerful and more flexible to control. But it's hard to understand for artist. some parameters based curve should be applied such as bezier curve.
[b]2. Some predefined effect with parameters:[/b]
Brightness and Contrast in GIMP
More easy to understand.So, most of software will support it.
There's many kinds of color correction effect exist. Different software will support different subset of them.
Brightness
Make whole scene more bright or more dark.
Contrast
Make whole scene have more contrast, dark more dark, bright more bright.With negative value, it will reduce the effect.
Hue
Change color hue.
Saturation
Change color saturation.
Exposure
Control the exposure of image.
Color balance
Control the color balance of image.
Gamma
Normally, convert from RGB to sRGB.
...
When combining different effects together, three different solutions exist:
1. Each effect is treated as one node with parameters. Then all effect nodes will applied one by one according the order in the sequence.
2. Some effects are combined into small groups. A static order of the effects are used in the group. Several small group will be applied one by one.
3. Combine all supported effects into one group. The group can be applied more than once.
Most of software also support only affect these effect on separate color channel(R, G, B, H, S, V, L). Some of effect can only affect shadows(such as [0,0.2]), midtones(such as (0.2,0.7]), highlights(such as (0.7,1.0]). Different software have different
subset of color correction effects. Even same color correction effect will be implemented by different method(mathematical function or curve).
Conclusion
As previous description about Lynx color correction feature and the research result of different software. Following is the design:1. A new computer shader will be used to generate 3D LUT texture at runtime; It should be executed every frame or only some special frame according to performance requirement;
2. The 3D LUT texture should be small size to reduce the texture fetching cost on GPU; At same time keeping good visual quality; Similar with Trials Fusion, it's 32x32x16.
3. To keep high performance and simplify the usage, all support color correction features are combined into one shader with static order:
Contrast
Hue, Saturation and Exposure
Brightness
Color balance
Gamma
4. Different color correction effect has some parameter to control result. They are all exposed in shader constant buffer, the correct values are need to calculated in CPU side.
Detail implementation refer to HDR demo.
There are many color correction effects for different purpose, current implementation only realize basic color correction effect. Some other effect can be added later according to requirement.
Contrast
<new color> = <old color> + <contrast> * (<old color> - 0.5)
Hue, Saturation and Exposure
All these operation are done in HSL color space, luminace value is used to simulator exposure.
<new color> = convertHSLToRGB( convertRGBToHSL(<old color>) * <hue, saturation, exposure> )
Brightness
<new color> = <old color> + <constant>
Color balance
<new color> = <old color> * <color balance(r,g,b)>
Gamma
<new color> = pow( <old color>, 1/gamma)
Reference:
Color correction on Wiki: http://en.wikipedia.org/wiki/Color_correction
Color grading on Wiki: http://en.wikipedia.org/wiki/Color_grading
Using Lookup Tables to Accelerate Color Transformations: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html
Brightness, Constrast, Saturation, and Sharpness: http://www.steves-digicams.com/knowledge-center/brightness-contrast-saturation-and-sharpness.html
List of color space and their uses: http://en.wikipedia.org/wiki/List_of_color_spaces_and_their_uses
Unreal3 HSV&RGB conversion function: http://wiki.beyondunreal.com/HSV-RGB_Conversion
Unreal Legacy:Colors: http://wiki.beyondunreal.com/Legacy:Colors
NVIDIA shader library(color space operation): http://developer.download.nvidia.com/shaderlibrary/webpages/hlsl_shaders.html
Optimized RGB to HSL/HSV and HSL/HSV to RGB: http://www.chilliant.com/rgb2hsv.html
Color grading in blender: http://wiki.blender.org/index.php/Doc:2.6/Manual/Composite_Nodes/Types/Color
Enhancing Photographs in Gimp: http://docs.gimp.org/en/gimp-imaging-photos.html
CLUT: http://www.quelsolaar.com/technology/clut.html
相关文章推荐
- C# 利用HttpListener监听处理Http请求
- AsyncTask源码分析
- Mac环境下服务器搭建
- 代码重构 —— 区分代码和数据
- php防止sql注入
- ERP流程一 总体说明
- 《foreach循环示例》
- windows下安装解压缩mysql
- #Codeforces 343 [div2] D. Babaei and Birthday Cake 【线段树优先队列查询优化】
- [置顶] 嗨~大家好,欢迎大家来这逛逛
- Python迁移MySQL数据到MongoDB脚本
- 系统启动流程
- 我有一个梦想
- [转载]Python标准库:内置函数sum(iterable[, start])
- 一条Log引发的血案
- DHCP协议原理及其实现流程
- ExpandableListView修改group图标
- windows主线程等待子线程退出卡死问题
- 数据库基础知识练习题
- 多线程还是多进程的区别