public static float Gen2(Vector2 position) { Vector2 p = new Vector2((int)Math.Floor(position.x), (int)Math.Floor(position.y)); Vector2 d = position - p; float[,] values = new float[2, 2]; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 2; ++j) { Vector2 gradient = RandomUnit2((int)p.x + i, (int)p.y + j); Vector2 distance = new Vector2(d.x - i, d.y - j); values[i, j] = Vector2.Dot(gradient, distance); } } Vector2 t = SCurve2(d); return(Interpolation.BiLerp(values[0, 0], values[1, 0], values[0, 1], values[1, 1], t)); }