I am trying to wrap a sphere with a patterned texture, while using code to handle the object being stretched/resized without stretching the pattern. Unfortunately, some of my triangles are displaying severely bunched up renditions of the pattern, as seen below.
I am pretty confident that this is due to the fact that the UV seam is going through these triangles, so when reassigning a UV to each triangle based on the normal of each vertice, it crosses values across the seam and puts in a much larger than needed selection of the pattern.
For the sake of fixing this with the tools I have available, I want to fix this via scripting. I believe one way to do it would be with the following pseudocode made into real code:
If the triangle has verticies with very different normals:
Split the triangle into 4 identical right triangles (using edge midpoints)
Add those 4 triangles into the mesh while removing the previous one
Ensure the new vertice normals are properly calculated
Return to the If statement for each of the 4 new triangles
Here’s where I need help: How do I build this functionality in my script? I’m having trouble making this flow a reality with proper structure/syntax. I am using Unityscript, so it would need to be formatted as such.
Any help would be incredibly appreciated. Thank you.

