I'm working with shaders so far, but I'm not sure how I can make my shader gl_FragCoord relative to the window. To be more clear, this is what I have:
and this is what I'm looking to achieve no matter where I place the fragment on the screen:
As you can see, the shader take the whole window as the refference canvas insted of the fragment. I'm playing with ranges and division based on resolution and fragment size/position, but couldn't figure it out.
The second image was compiled based on hardcoded data, need to find a general solution..
EDIT: This is my vert & frag glsl code:
#version 330 core
layout(location = 0) in vec2 position;
void main() {
vec2 fp = vec2(position.x, position.y);
gl_Position = vec4(position.x, position.y, 0.0, 1.0 );
};
$
#version 330 core
layout(location = 0) out vec4 color;
void main() {
vec2 pos = gl_FragCoord.xy/vec2(800., 600.);
float r = 0.4 / 2.0;
float c = smoothstep(r, r - 0.01, distance(pos, vec2(0.5)));
color = vec4(vec3(c) * vec3(0.0, 0.5,1.0), 1.0);
};