基于Qt的OpenGL可编程管线学习(15)-颜色加深、颜色减淡、想家相减
1、颜色加深
网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了旌阳免费建站欢迎大家使用!
shader
//颜色加深
uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;
varying vec2 M_coord;
void main()
{
vec4 blendColor = texture2D(U_SubTexture, M_coord);
vec4 baseColor = texture2D(U_MainTexture, M_coord);
gl_FragColor = vec4(1.0) - (vec4(1.0) - baseColor) / blendColor;
}效果图

2、颜色减淡
shader
//颜色减淡
uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;
varying vec2 M_coord;
void main()
{
vec4 blendColor = texture2D(U_SubTexture, M_coord);
vec4 baseColor = texture2D(U_MainTexture, M_coord);
gl_FragColor = baseColor / (vec4(1.0) - blendColor);
}效果图

3、相加
shader
//相加
uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;
varying vec2 M_coord;
void main()
{
vec4 blendColor = texture2D(U_SubTexture, M_coord);
vec4 baseColor = texture2D(U_MainTexture, M_coord);
gl_FragColor = blendColor + baseColor;
}
4、相减
shader
//相减
uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;
varying vec2 M_coord;
void main()
{
vec4 blendColor = texture2D(U_SubTexture, M_coord);
vec4 baseColor = texture2D(U_MainTexture, M_coord);
gl_FragColor = vec4(baseColor.rgb - blendColor.rgb, 1.0);
}效果图

当前标题:基于Qt的OpenGL可编程管线学习(15)-颜色加深、颜色减淡、想家相减
新闻来源:http://www.jxjierui.cn/article/pecjgp.html


咨询
建站咨询
