问题
I'm new to OpenGL and GLSL Programming. Recently I need to do freehand masking on an image like below Image. How could I achieve this using Fragment Shader?
Currently, I am trying this with below fragment shader but Nothing Change on Image.
precision mediump float;
varying vec2 v_TexCoordinate;
varying vec2 v_TexCoordinate2;
uniform sampler2D u_Texture;
uniform sampler2D u_Texture2;
uniform bool u_alpha_test_enable;
void main()
{
float mask = texture2D(u_Texture, v_TexCoordinate).a;
// if (u_alpha_test_enable && mask < 0.4) discard;
gl_FragColor = texture2D(u_Texture2, v_TexCoordinate2) * vec4( 1,1,1,mask );
}
I want an effect like below Image.
来源:https://stackoverflow.com/questions/56087305/how-do-i-create-free-hand-mask-on-image-like-below-using-glsl-shader-in-android