/// <summary> /// 双线性插值 /// @---->*<--@ /// ↓ /// # /// ↑ /// @---->*<--@ /// </summary> /// <returns></returns> private float _Lerp2D(uint x1, uint y1, uint x2, uint y2, float tx, float ty) { tx = RMGUtility.SmoothCurve(tx); ty = RMGUtility.SmoothCurve(ty); return(RMGUtility.Lerp( RMGUtility.Lerp(_permutaion[x1, y1], _permutaion[x2, y1], tx), RMGUtility.Lerp(_permutaion[x1, y2], _permutaion[x2, y2], tx), ty)); }
/// <summary> /// 1D coherent noise /// </summary> public float GetPixel(float x) { x = Mathf.Min(_to, x); x = Mathf.Max(_from, x); x -= _from; x *= _scale; // 整数 if ((ushort)x == x) { return(_permutation[(ushort)x]); } int left = Mathf.FloorToInt(x); int right = Mathf.CeilToInt(x); float t = RMGUtility.SmoothCurve(x - left); return(RMGUtility.Lerp(_permutation[left], _permutation[right], t)); }