Updated the code. This time it should actually be correct.
Right now it maps the uv coords to a sphere.
Vector3 p1 = new Vector3(0, -1f, 0);
Vector3 p2 = new Vector3(1f, 1f, 0);
Vector3 p3 = new Vector3(0, 1f, 1f);
Vector2 uv1 = new Vector2(.5f, 1f);
Vector2 uv2 = new Vector2(0, 0);
Vector2 uv3 = new Vector2(0, 1f);
float lat1 = Mathf.Acos(p1.y);
float lat2 = Mathf.Acos(p2.y);
float lat3 = Mathf.Acos(p3.y);
float lon1 = Mathf.Atan(p1.z);
float lon2 = Mathf.Atan(p2.z);
float lon3 = Mathf.Atan(p3.z);
float s = lat3 * Mathf.Rad2Deg;
float e = lat1 * Mathf.Rad2Deg;
float la = 1f / (e - s);
float ii = 0;
for (float i = s; i <e; i+=1f)
{
Vector2 luv = Vector2.Lerp(uv3, uv1, la * ii);
Vector2 ruv = Vector2.Lerp(uv2, uv1, la * ii);
ii += 1f;
float x = Mathf.Sin(i * Mathf.Deg2Rad) * Mathf.Cos(lon2);
float x2 = Mathf.Sin(i * Mathf.Deg2Rad) * Mathf.Cos(lon3);
x *= Mathf.Rad2Deg;
x2 *= Mathf.Rad2Deg;
int i1 = (int)i+(h-180)/2;
int j1 = (int)x + w / 2;
int j2 = (int)x2 + w / 2;
float laa = 1f / (j1 - j2);
float jj = 0;
for(float j = j2; j <= j1; j+=1f)
{
Vector2 uv = Vector2.Lerp(luv, ruv, laa * jj);
jj += 1f;
c[(int)j + (int)i1 * w] = new Color(uv.x, uv.y, 1f, 1f);
}
}