GLSL vertex shader wireframe third vertex

Hi to all. I have a problem with indexing the third vertex of the mesh in the vertex shader. I use a one-dimensional array that stores the vertices of the future mesh to pass them into a geometric shader, but I can’t get the index of the third vertex since the vertices are sorted according to the incrisis principle, in the code I use a uniform that contains the value of the row from the geometry. If you use another mesh with an unknown amount of rou, then my solution will not work. How can I get a third vertex equivalent to the principle that is embedded in the geometric shader as <gl _in [index] .gl _Position> but at the same time I use “ in” which does not allow me to get the third vertex of the grid because it only works with vertices, not primitives. Thanks.

lines_ver3.toe (6.4 KB)

Hi there maimaimai,

You can use the layout qualifier for this. Instead of using layout (points) in, you can use layout (triangles) in. See: Layout Qualifier (GLSL) - OpenGL Wiki

When using the ‘triangles’ in, the first 3 elements of the iVert[] array will be set.
Hope this helps…

cheers,
tim

Hi, thanks for the reply. But how it looks in the code. I tried to do it, but the material is not displayed. Here is a modified version.
lines_ver4.toe (6.3 KB)

Hi there,

Since you are now using triangles instead of points, you shouldn’t convert the sop to a particle system but keep it as a mesh. Also I’m not sure about the material SOP and how much is actually runs your shader (seems to work in this case, but had troubles in the past). I usually just use a geoCOMP to see the result (see geo1).

Cheerio
tim

lines_ver4_update.tox (3.9 KB)

I know this way how to get tops from a triangular mesh. The bottom line is that I use not triangles, but input points from which I already create a mesh in the geometric shader, in my next task I will only deal with vertex. My problem is to get a vertex index similar to the principle that “layout triangles” works. I need to understand the principle by which he finds the third vertex by which he builds a triangle.

aah I think they are supplied to the shader by the CPU. So they are set in the SOP in touchdesigner. You can access them using the soptoDat and dattoSop. See attached example.

If you want to displace triangles, you can render a sphere or something (that has triangles), then using a soptoDAT to find the triangle indices per vertex (perhaps some code needed to supply it as a lookup inside the shader)…

Or you just create only 1/3 of the vertices and supply the other 2 vertex positions as an extra buffer (so in the vertex shader you have access to all 3 of them). You can use those to create your triangle inside the geometry shader. (haven’t tested this so not sure if it would work :))

Cheers,
tim

SopTriangles.tox (742 Bytes)

Thanks for example. But I’m trying to build a mesh without using geometry that will have triangles. I need to think about its construction and distribution of indexes, but I have no ideas. I looked at mesh generation algorithms; they are mostly related on opengGL internal things. I can try writing delaunay triangulation but not the fact that it will display correctly. So far I can’t solve this problem. Such things are still easier to write on the CPU and not on the GPU, although it gives high performance.

Hi. I found a short article on creating indecies. I think this will help.
http://www.codercorner.com/Strips.htm