UV mapping a sphere, giving problems at poles
Hi, i procedually generated a sphere, and everything seems to work fine except for the UV's I get some weird distortion around the poles, and a weird line down the side of the sphere.
I have an array with all my verticies called newVerticies. I have one vertex on the pole, and lines running from pole to pole with verticies. This is the code i use to genereate my UV's
void GenerateUVs()
{
newUV = new Vector2[newVertices.Length];
for (int i = 0; i < newUV.Length; i++)
{
Vector3 d = (transform.position - newVertices[i]).normalized;
newUV[i] = new Vector2(0.5f+(Mathf.Atan2(d.z,d.x)/(2*Mathf.PI)),0.5f-(Mathf.Asin(d.y)/Mathf.PI));
if (i == 0 || i == newUV.Length-1)
{
print(newUV[i]);
}
}
}
I Hope anyone have tried this before, and could possible tell me whats wrong. My suspicion is that it it not looping right so to speak. It lookes like the whole texture is repeating in that little strip, but that is my best quess.
Your answer
Follow this Question
Related Questions
UV coordinates to be stored by Control Points 1 Answer
Generating a sprite from a script,Trying to generate a sprite from a script 0 Answers
UV tiling with already made coordinates. 1 Answer
Can I add the same UV coordinates to multiple vertices? 0 Answers
How to get the specified material for a given uv coordinate 0 Answers