How do I create free hand mask on Image Like below using glsl Shader In android?

こ雲淡風輕ζ 提交于 2019-12-13 03:16:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!