颜色混合说明

2020/03 27 10:03

颜色混合公式:

FinalColor= (SrcColor* SrcBlend) BlendOp (DesColor* DestBlend)

即:最终RGB值 = (上层图的RGB * SrcBlend )BlendOp(下层图的RGB * DstBlend)

SrcBlend 和 DstBlend 可取以下值
Zero:永远取0
One:永远取1
DstColor:下层图的RGB
SrcColor:上层图的RGB
OneMinusDstColor: 1-下层图RGB
SrcAlpha :上层图片的Alpha值
OneMinusSrcColor: 1-上层图RGB
DstAlpha :下层图片的Alpha值
OneMinusSrcAlpha: 1-上层图Alpha
SrcAlphaSaturate:取最小值(上层图Alpha,1-上层图Alpha)
OneMinusDstAlpha: 1-下层图Alpha

BlendOp可以取以下值
Add: 加法
Sub: 减法
RevSub: 反减
Min:取两者小值
Max:取两者大值

Add	Add source and destination together.
Sub	Subtract destination from source.
RevSub	Subtract source from destination.
Min	Use the smaller of source and destination.
Max	Use the larger of source and destination.

示例1-经典透明图片混合算法:
SrcBlend选SrcAlpha,DestBlend选OneMinusSrcAlpha,BlendOp选Add
则:输出值 = 上层图RGB*上层图Alpha + 下层图RGB*(1-上层图Alpha)

示例2-叠加算法a:
SrcBlend选SrcAlpha, DestBlend选One,BlendOp选Add
则:输出值= 上层图RGB*上层图Alpha + 下层图RGB

示例3-叠加算法b:
SrcBlend选One, DestBlend选One,BlendOp选Add
则:输出值= 上层图RGB + 下层图RGB

--转载请注明: http://blog.coolcoding.cn/?p=1460

发表回复

欢迎回来 (打开)

(必填)