- Home /
Question by
gonzalitosk8 · Jan 15, 2020 at 07:27 PM ·
errorprocedural meshuv mappingstretching
uv map problems
Hello community! I need help with this problem. I am making a procedural mesh system. I'm having an error with uv mapping. the texture is well placed, but there are times that it stretches too much in certain positions, mostly in diagonals between nodes. I leave some pictures of how it looks, and the code to analyze it!
Thanks a lot!
Vector2[] uvs = new Vector2[SelectedMesh.verts.Count];
for (int i = 0; i < uvs.Length; i++){
Vector3 heading = new Vector3(SelectedMesh.verts[i].x, 1, SelectedMesh.verts[i].z);
Vector3 direction = heading / heading.magnitude;
uvs[i] = new Vector2(((SelectedMesh.verts[i].x * direction.x) + (SelectedMesh.verts[i].z * direction.z)) / styles.TexScaleX/1.6f, SelectedMesh.verts[i].y / styles.TexScaleY/1.6f);
uvs[i] = new Vector2(uvs[i].x + SelectedMesh.TexOffsetX,uvs[i].y + SelectedMesh.TexOffsetY);
}
SelectedMesh.BuildingMesh.uv = uvs;
Comment
Your answer
Follow this Question
Related Questions
Generate Lightmap UV at Runtime 0 Answers
Merging faces without effecting texture mapping 2 Answers
need guide in uv texture 0 Answers
How to calculate uvs for roof procedurally generated? 3 Answers
UV Mapping: extra pixels either side 1 Answer