I’m trying to create a simple masking fragment shader, which takes as input a mask texture (texture 1), as well as an image texture to mask (texture 0).
In pseudocode, I’m calling the following:
fboMask.allocate(some width, some height); fboMask.begin(); ofClear(0); ...draw some sort of black and white mask fboMask.end(); maskShader.begin(); maskShader.setUniformTexture("imageMask", fboMask.getTexture(), 1); image.drawSubsection(...); maskShader.end();
In the vertex shader, I am setting varying texCoordVarying = gl_MultiTexCoord0.xy
The problem I’m having though is in my fragment shader, when I sample both tex0 and imageMask with texture2DRect(texture, texCoordVarying), it works ok only for tex0 (the image.subsection texture) and not for sampling the imageMask texture - the coordinates on this one seem way off.
Am I supposed to set something in GL from my vertex shader or OpenFrameworks code before running this fragment shader, to inform it about how to sample my imageMask texture as well?
Thanks for the help!