GLSL surface reconstruct

Hi. I have a problem with the correctness of the closure of my surface. I use array uniforms to pass vertex in shader geometry. The surface does not close as I understand it in the start and end vertices of the array. When using the “P” attribute, such problems do not arise, as well as in the shader geometry “gl_in”. I have no idea how to close the surface, I hope for your help. Thanks.

lines.toe (5.3 KB)

In your shader

int vert = gl_VertexID%pointNum;
oVert.pt1 = points[vert];
oVert.pt2 = points[(vert+1)];
oVert.pt3 = points[(vert+42)];

should become

int vert = gl_VertexID%pointNum;
oVert.pt1 = points[vert%pointNum];
oVert.pt2 = points[(vert+1)%pointNum];
oVert.pt3 = points[(vert+42)%pointNum];

The modulo operation has to take place after addition, otherwise you leave array bounds.

1 Like

Thanks for the reply and advice.