码迷,mamicode.com
首页 > 其他好文 > 详细

基于Qt的OpenGL可编程管线学习(17)- 差值、反差值、排除

时间:2017-06-01 00:29:46      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:qt   opengl   shader   差值   反差值   排除   

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 = abs(vec4(blendColor.rgb - baseColor.rgb, 1.0));
}

效果图

技术分享


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 = vec4(vec3(1.0) - abs(vec3(blendColor.rgb - baseColor.rgb)), 1.0);
}

效果图

技术分享


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 = vec4(blendColor.rgb + baseColor.rgb - 2.0 * blendColor.rgb * baseColor.rgb, 1.0);
}

效果图

技术分享

本文出自 “不会飞的纸飞机” 博客,请务必保留此出处http://douzhq.blog.51cto.com/12552184/1931106

基于Qt的OpenGL可编程管线学习(17)- 差值、反差值、排除

标签:qt   opengl   shader   差值   反差值   排除   

原文地址:http://douzhq.blog.51cto.com/12552184/1931106

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!