Hi, Basically i want to draw simple thin lines between vertices on say on a plain, and i dont mean lines on the edges i mean line between vertices so that even the vertices on the inside of the plain have lines between them, Note that i don’t want the line to cross diagnolly.
simply like this: (with the vertices being in the crossings of the lines, Obviously)
also the plain is proceedurally generated at runtime and vertices are going to be moving alot for different effects, meaning the lines have to always be between them and updating with their movement.
is there a way to achive this,preferably using shader graph (so that i can adjust it for more lighting effects across the grid of lines).
also performance really matters to me.
searched around to find nothing except those from like 2011 - 2014 and i feel like there has got to be a much easier way to so instead of the old methods
This question is a bit confusing. When you create your mesh procedurally you most likely are creating triangles. You can simply create a second mesh using the same vertices array but instead of creating triangles you can use a different topology. In your case you can simply use MeshTopology.Lines or simply MeshTopology.LineStrip.
In the “Lines” topology the indices will always form single line segments. So always 2 consecutive indices will represent a single line.
In the Linestrip topology the indices will form a strip of line segments. The the first index will connect to the second, the second to the thrid and so on. However AFAIK you can not simply stop a linestrip and restart it elsewhere since it’s a continues strip of lines. With trianglestrips it’s possible to use degenerative vertices to collapse the triangle between the end and the start of the new strip into a line which would be invisible. This is not really possible with linestrips. So the best choice is probably just “Lines”.
If you need those lines to be a fix part of your mesh you might just add the lines as a submesh with its own material to the same mesh. However if you really want to use a shader to just draw the grid onto the mesh itself be aware that your mesh need to be unwrapped properly. So you have to have some kind of UV mapping in place. Also keep in mind if you’re essentially rendering the lines in texture space they will be affected by perspective (if you use a perspective camera). So they will appear larger when they are closer to the camera. Here’s a very simple example in shader graph how you can generate a grid. As long as you aligned the uvs and scaling correctly the “lines” would stay aligned with your vertices.