Glitches with 'texture' function in glsl top

Dear Designers, hope you can help me with the issue I’ve been struggling for weeks and just hitting a brick wall. Let me try explain it all…

I’m drawing a grid of poligons in GLSL and want their size be determined by an input TOP.
It all works well with one polygon in each cell but as I want to make poligons go outside 0-1 coordinates and overlap I decided to draw 9 poligons: main center and 8 poligons around that are outside coordinate system but sides are visible if they are large enough. And it all almost works, apart from the lines that sometimes appear on the edges of each cell.
Those glitches definetely depend on the number of rows/columns and resolution (when the reminder is zero, ie 1000x1000px with 10x10 grid). But as I understand it’s not just an odd pixels as TD definetely trying to draw something there, it is pretty consistant line that matches the size of the opposite cell… Also when I make similar gradient without input TOP it all works well without any glitches.

Please excuse my poor TD vocablurary. Any help with tips on where I can educate myself about the issues above will be greatly appreciated.

Thanks!
Dina


Grid+input.4.toe (7.8 KB)

Ah… not sure how I can share the network… I guess I’m too beginner to do it :flushed: :roll_eyes: :sob:

Hey @dina.silanteva,

you should be able to post a file now.

cheers
Markus

1 Like

Hey @dina.silanteva,

from what it looks like, for certain conditions the st calculations end up between 2 pixels and the wrong values are retrieved.

When defining the sts for all different directions, calculate first the input pixel, then offset by the required amount plus half a pixel width and convert that back to a float uv to be used in the texture lookup:

    // calculate the theoretical pixel
    vec2 lookUpSt = floor(st * zoom.xy);
    // calculate the theoretical pixel size
    vec2 pixelSize = vec2(1.0) / zoom;
    // convert back to 0-1 uv values and offset by half a pixel
    vec2 lst = lookUpSt / zoom + pixelSize/2;
 	
    vec2 stTopL = vec2(lst.x-1/zoom.x, lst.y+1/zoom.y);
    vec2 stTopCn = vec2(lst.x, lst.y+1/zoom.y);
    vec2 stTopR = vec2(lst.x+1/zoom.x, lst.y+1/zoom.y);
    vec2 stCnL = vec2(lst.x-1/zoom.x, lst.y);
    vec2 stCnCn = lst;
    vec2 stCnR = vec2(lst.x+1/zoom.x, lst.y);
    vec2 stBtL = vec2(lst.x-1/zoom.x, lst.y-1/zoom.y);
    vec2 stBtCn = vec2(lst.x, lst.y-1/zoom.y);
    vec2 stBtR = vec2(lst.x+1/zoom.x, lst.y-1/zoom.y);

Hope this helps
Markus

1 Like

@snaut this is amazing, works perfectly! I’ll name my cat Theoretical Pixel in your honour! :smiling_face_with_three_hearts:
Thank you!

1 Like

rolls very well of the tongue :slight_smile:

1 Like