I am trying to create a planet that uses a heightmap in a spherical manner. I have gotten it to read from an image using the grayscale for height alright but there is an issue.
Since Vector3.Angle does not pay attention to the direction of the angle I am getting a mirror image on my planet like so:
That’s an interesting problem. (I hate math but like seeing being applied). The Vector3.Angle I believe that will always return the closest angle. This is desirable in many situations. In your case, it feels more like dot product or something involving cosine (since they go from -1 to 1 relative to a vector, you can easily map half a circle). I found some answers that I will quote here:
/// <summary>
/// Determine the signed angle between two vectors, with normal 'n'
/// as the rotation axis.
/// </summary>
public static float AngleSigned(Vector3 v1, Vector3 v2, Vector3 n)
{
return Mathf.Atan2(
Vector3.Dot(n, Vector3.Cross(v1, v2)),
Vector3.Dot(v1, v2)) * Mathf.Rad2Deg
);
}