标签: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 = 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); }
效果图
本文出自 “不会飞的纸飞机” 博客,请务必保留此出处http://douzhq.blog.51cto.com/12552184/1931105
基于Qt的OpenGL可编程管线学习(15)- 颜色加深、颜色减淡、想家相减
标签:qt opengl shader 颜色加深 颜色减淡 相加相减
原文地址:http://douzhq.blog.51cto.com/12552184/1931105