I have a fullscreen sized quad, now i draw it on screen then in fragment shader i choose whenever linenis visible or not and draw it on screen (2d grid rendering)
However when i zoom out lines dissapear not to mention i cant achieve one thickeness regardless of the zoom
Left zoomed in right and below zoomed out
And heres the shader
precision highp float;
uniform vec3 translation;
uniform float grid_size;
uniform vec3 bg_color;
uniform vec3 grid_color;
uniform float lthick;
uniform float sw;
uniform float sh;
uniform float scale;
varying vec3 vc;
int modulo(float x, float y)
{
return int (x - y * float ( int (x/y)));
}
float modulof(float x, float y)
{
return x - y * float ( int (x/y) );
}
void main()
{
bool found = false;
vec2 fragcoord = vc.xy * 0.5 + 0.5;
//find how much units do we have in worldspace for a halfspace
vec2 sc = ( vec2(sw, sh) / 2.0 ) / scale;
sc = sc * vc.xy + translation.xy; //world position
int px = modulo(float (sc.x), grid_size);
int py = modulo(float (sc.y), grid_size);
if ( (px == 0) || (py == 0) )
found = true;
if (found)
gl_FragColor = vec4(grid_color, 1.0);
else
gl_FragColor = vec4(bg_color, 1.0);
}
I know that when zooming out, a fragment can not represent actual grid line.