Transform point to gl_ModelViewProjectionMatrix space

I have a shader that I’m using to some clipping (source below). I need to set the clipping area in terms of the current drawing state. It seems I need to transform the coordinates I want to use by the inverse of the GL_MODELVIEW_MATRIX but it doesn’t work quite right. I’ve seen some other posts that mention the need to take the default OF transform into account but I’m not sure 1) had to get that and 2) how to properly apply it. Any pointers would be greatly appreciated!

Here is the calling code

m_rectMaskShader.begin();

		float myMatrix[16];
		glGetFloatv(GL_MODELVIEW_MATRIX, myMatrix);
		ofMatrix4x4 gti = ofMatrix4x4(myMatrix).getInverse();

		ofPoint ul = ofPoint(0,0);
		ofPoint lr = ofPoint(300, 300);

		ul = ul * gti;
		lr = lr * gti;

		m_rectMaskShader.setUniform2f("upperLeft", ul.x, ul.y);
		m_rectMaskShader.setUniform2f("lowerRight", lr.x, lr.y);

		img->draw();

		m_rectMaskShader.end();

And the shaders, vertex:

#version 120
#extension GL_ARB_texture_rectangle : enable
#extension GL_EXT_gpu_shader4 : enable

varying vec4 position;

void main() {
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
	position = gl_Position;
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_FrontColor = gl_Color;
}

and fragment:

#version 120
#extension GL_ARB_texture_rectangle : enable
#extension GL_EXT_gpu_shader4 : enable

varying vec4 position;

uniform sampler2DRect texture0;

uniform vec2 upperLeft;
uniform vec2 lowerRight;

void main(){
	if ((position.x < upperLeft.x) || (position.y < upperLeft.y) || (position.x > lowerRight.x) || (position.y > lowerRight.y)) {
		//discard;
		//Getting coordinates of the current pixel in texture
		vec2 pos = gl_TexCoord[0].xy;

		//Getting the pixel color from the texture texture0 in pos
		vec4 color = texture2DRect(texture0, pos);
		color.r = 1.0 - color.r;
		color.g = 1.0 - color.g;
		color.b = 1.0 - color.b;
		
		//Output the color of shader
		gl_FragColor = color;
	} else {
		//Getting coordinates of the current pixel in texture
		vec2 pos = gl_TexCoord[0].xy;

		//Getting the pixel color from the texture texture0 in pos
		vec4 color = texture2DRect(texture0, pos);

		//Output the color of shader
		gl_FragColor = color;
	}
}