- Home /
Why is there a MeshUtility.SetPerTriangleUV2
According to the Unity script reference:
For every vertex there can be a normal, two texture coordinates, color and tangent.
According to Wikipedia, (and I know this is the case in OpenGL).
UV coordinates are applied per face,[3] not per vertex. This means a shared vertex can have different UV coordinates in each of its triangles, so adjacent triangles can be cut apart and positioned on different areas of the texture map.
Unity seems to support this through `MeshUtility.SetPerTriangleUV2`. Why? Why can I not set per-triangle uv coordinates for the primary texture?
I'm trying to create a web-banner-like mesh automatically. That is, tile the center of each block, but use another sprite/submesh/subtexture for the ends.
Answer by Bunny83 · Mar 29, 2013 at 04:48 PM
Just found your question. MeshUtility is an editor class and SetPerTriangleUV2 isn't documented or has been removed, so it's probably used internally by the editor.
Next thing is the graphics card can only use one index for all "vertex parameters". I worked a lot with OpenGL in the past but mostly with the immediate API ;) However I've never heard of a way to specify the uvs seperately when using indexed buffers. See this SO question.
I guess the function is used by the lightmapper for specifying the lightmap UVs.
Fact is that you have to split a vertex when any vertex property is different (position, normal, color, uv, uv2, tangent)
Your answer
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
2 Textures on a single mesh 1 Answer
"Baking" to 2d UV Map? 1 Answer
Texture bleeding on mesh 2 Answers