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

发布时间:2020-05-30 14:00:54 作者:Douzhq
来源:网络 阅读:492

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));
}

效果图

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


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);
}

效果图

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


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);
}

效果图

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

推荐阅读:
  1. Unity3d学习 相机的跟随
  2. 关于安卓的TranslateAnimation的使用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

qt opengl shader

上一篇:mysql8.0忘记登录密码怎么办

下一篇:JavaScript运用cookie的操作

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》