I am studying OpenGL ES 2.0 and I would like to create an application to better understand how it works. The application has a set of filters that the user can apply on images (I know, nothing new: P).
One of these filters takes two images and a mask and mixes the two images, displaying them through the mask (here the image better explains what I want to get)

I'm really confused at the moment, and I don't know where to start creating this effect. I canโt understand that I need to work with several textures and several FrameBuffers, or I can just work with one shader.
Do you have any hint to help me in this project?
EDIT --------
I found this solution, but when I use masks instead of circles as lines, the result is really โgrungyโ, especially if the lines rotate.
precision highp float; varying vec4 FragColor; varying highp vec2 TexCoordOut; uniform sampler2D textureA; uniform sampler2D textureB; uniform sampler2D mask; void main(void){ vec4 mask_color = texture2D(mask, TexCoordOut); if (mask_color.a > 0.0){ gl_FragColor = texture2D(textureA, TexCoordOut); }else { gl_FragColor = texture2D(textureB, TexCoordOut); } }
Perhaps it is better to use a stencil buffer or mix?
Mattergoal
source share