hello, I'm writing a simple fragment shader that multiplies the rgba of a fragment based on it's distance from my mouse position.
varying vec4 vColor;
varying vec2 vTexCoord;
uniform sampler2D uTexture;
uniform vec2 uLightPosition;
void main(){
float pixelDistFromLight = distance(uLightPosition, vec2(gl_FragCoord.x, gl_FragCoord.y));
vec4 modColor = vec4(vColor.r + -pixelDistFromLight/100.0, vColor.g + -pixelDistFromLight/100.0,
vColor.b + -pixelDistFromLight/100.0, vColor.a );
gl_FragColor = texture2D(uTexture, vTexCoord) * modColor ;
}
the 'light' follows the mouse from left to right, but it's movement is inverted on the y axis. I understand that this is because glsl uses the bottom left as it's origin, and have tried to invert it in various ways including 1.0 - gl_FragCoord.y, and although that makes the light move in the righ direction, the light is still not situated at the mouse positions. i.e it moves up when i move the mouse up, but is positioned at the bottom of the screen.
any idea what operation i could perform on gl_FragCoord.y to get it to match the y coordinate of my mouse?
thanks for your time.