I've been trying to do some masking in OpenGL and GLSL, but the resources I've found online usually assume that textures and their masks have the same dimensions and no transformations (Images and mask in OpenGL ES 2.0)
I have a mask (pink circle) that has been translated and I have a texture (red square) that can be further translated and rotated behind the mask. I would like to display the portion of the red square under the pink circle.
The other questions I've seen either reuse the existing texture coordinate because the texture and mask are the same dimensions, or they have an additional texture coordinate for the mask (https://gamedev.stackexchange.com/questions/93893/opengl-positional-2d-texture-masking) that I'm not sure how they got.
How can I apply distinct transformations to a mask and texture of different dimensions and only display the overlap? I've considered doing something similar to a shadow map, rendering any mask textures first, getting the depth map, and then sampling that in my fragment shader whenever I want to mask something. I have a shadow map implemented so that would allow me to reuse some code. Is that a good solution?