您的位置:首页 > 运维架构

opengl实现PS中部分图像处理效果-正片叠底、逆正片叠底、颜色加深、减淡

2017-09-12 18:32 1256 查看
效果图



正片叠底shader

varying vec2 V_Texcoord;

uniform sampler2D U_BaseTexture;
uniform sampler2D U_BlendTexture;

void main()
{
vec4 blendColor=texture2D(U_BlendTexture,V_Texcoord);
vec4 baseColor=texture2D(U_BaseTexture,V_Texcoord);
//r,g,b,a
gl_FragColor=blendColor*baseColor;
}
逆正片叠底shader

varying vec2 V_Texcoord;

uniform sampler2D U_BaseTexture;
uniform sampler2D U_BlendTexture;

void main()
{
vec4 blendColor=texture2D(U_BlendTexture,V_Texcoord);
vec4 baseColor=texture2D(U_BaseTexture,V_Texcoord);
//r,g,b,a
gl_FragColor=vec4(1.0)-((vec4(1.0)-blendColor)*(vec4(1.0)-baseColor));
}
颜色加深shader

varying vec2 V_Texcoord;

uniform sampler2D U_BaseTexture;
uniform sampler2D U_BlendTexture;

void main()
{
vec4 blendColor=texture2D(U_BlendTexture,V_Texcoord);
vec4 baseColor=texture2D(U_BaseTexture,V_Texcoord);
//r,g,b,a
gl_FragColor=vec4(1.0)-(vec4(1.0)-baseColor)/blendColor;
}


颜色减淡shader

varying vec2 V_Texcoord;

uniform sampler2D U_BaseTexture;
uniform sampler2D U_BlendTexture;

void main()
{
vec4 blendColor=texture2D(U_BlendTexture,V_Texcoord);
vec4 baseColor=texture2D(U_BaseTexture,V_Texcoord);
//r,g,b,a
gl_FragColor=baseColor/(vec4(1.0)-blendColor);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: