Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Coat Buttons
#4
(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
Reply


Messages In This Thread
Coat Buttons - by ncthbrt - 27-08-2018, 06:35 AM
RE: Coat Buttons - by josemendez - 27-08-2018, 06:38 PM
RE: Coat Buttons - by ncthbrt - 28-08-2018, 08:48 PM
RE: Coat Buttons - by josemendez - 29-08-2018, 08:54 AM
RE: Coat Buttons - by Wassink - 10-09-2018, 12:19 PM
RE: Coat Buttons - by josemendez - 10-09-2018, 02:09 PM