(28-08-2018, 08:48 PM)ncthbrt Wrote: Thanks! Tried that solution, but wasn't happy with the results (Think I needed multiple sample points, unless I'm indexing vertices at the wrong place. It's using the same index as the particle, right?). Ended up removing the buttons. Actually think it's less visually noisy at typical in-game scales.

Nope, particle indices and vertex indices usually have nothing in common. There's always one and only one particle at the end of any edge in the mesh. However in edges where uvs, normals, vertex colors, or any other per-vertex property is discontinuous (think an UV seam), each edge ends at its own vertex. Think of the corner of a cube, where 3 faces meet: if each face has a different normal (and usually they do) then there are 3 separate vertices at the corner, but only 1 particle. Each face will reference its own "copy" of the vertex, if you will.

Therefore, contiguous mesh triangles can index different vertices. This is what mesh.triangles is used for. See:

https://docs.unity3d.com/ScriptReference/Mesh.html
So usually you have many more vertices than particles. For any vertex in the mesh topology, you can get its corresponding particle:

Code:

`int particleIndex = cloth.topology.visualMap[vertexIndex];`

Doing it the other way around (getting a vertex for a particle, as there can be more than one) can be done by searching in the visualMap array (which is more expensive).

Smooth per-vertex normals (which are the ones used for rendering) are calculated by a weighted average of the face normals, for all incident faces. Most commonly used weights are triangle areas, edge angles or simple arithmetic mean. Sampling is usually not a good idea. If you are curious:

http://www.bytehazard.com/articles/vertnorm.html