作者:小白_king | 来源:互联网 | 2023-08-07 00:35
1、正片叠底shader 正片叠底uniform sampler2D U_MainTexture;uniform sampler2D U_SubTexture;varying vec2
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 = blendColor * baseColor;
}
效果图
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(1.0) - (vec4(1.0) - blendColor) * (vec4(1.0) - baseColor);
}
效果图