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);}
效果图