Vector3 GerstnerOffset4(Vector2 xzVtx, Vector4 _GSteepness, Vector4 _GAmplitude, Vector4 _GFrequency, Vector4 _GSpeed, Vector4 _GDirectionAB, Vector4 _GDirectionCD)
{
Vector3 offsets = new Vector3();
var stepAmpXX = _GSteepness.x * _GAmplitude.x;
var stepAmpYY = _GSteepness.y * _GAmplitude.y;
Vector4 AB = new Vector4(stepAmpXX * _GDirectionAB.x,
stepAmpXX * _GDirectionAB.y,
stepAmpYY * _GDirectionAB.z,
stepAmpYY * _GDirectionAB.w);
Vector4 CD = new Vector4(_GSteepness.z * _GAmplitude.z * _GDirectionCD.x,
_GSteepness.z * _GAmplitude.z * _GDirectionCD.y,
_GSteepness.w * _GAmplitude.w * _GDirectionCD.z,
_GSteepness.w * _GAmplitude.w * _GDirectionCD.w);
float dotA = Vector2.Dot(new Vector2(_GDirectionAB.x, _GDirectionAB.y), xzVtx);
float dotB = Vector2.Dot(new Vector2(_GDirectionAB.z, _GDirectionAB.w), xzVtx);
float dotC = Vector2.Dot(new Vector2(_GDirectionCD.x, _GDirectionCD.y), xzVtx);
float dotD = Vector2.Dot(new Vector2(_GDirectionCD.z, _GDirectionCD.w), xzVtx);
Vector4 dotABCD = new Vector4(dotA * _GFrequency.x, dotB * _GFrequency.y, dotC * _GFrequency.z, dotD * _GFrequency.w);
Vector4 TIME = new Vector4((Time.time * _GSpeed.x) % 6.2831f,
(Time.time * _GSpeed.y) % 6.2831f,
(Time.time * _GSpeed.z) % 6.2831f,
(Time.time * _GSpeed.w) % 6.2831f);
Vector4 COS = new Vector4(Mathf.Cos(dotABCD.x + TIME.x),
Mathf.Cos(dotABCD.y + TIME.y),
Mathf.Cos(dotABCD.z + TIME.z),
Mathf.Cos(dotABCD.w + TIME.w));
Vector4 SIN = new Vector4(Mathf.Sin(dotABCD.x + TIME.x),
Mathf.Sin(dotABCD.y + TIME.y),
Mathf.Sin(dotABCD.z + TIME.z),
Mathf.Sin(dotABCD.w + TIME.w));
offsets.x = Vector4.Dot(COS, new Vector4(AB.x, AB.z, CD.x, CD.z));
offsets.z = Vector4.Dot(COS, new Vector4(AB.y, AB.w, CD.y, CD.w));
offsets.y = Vector4.Dot(SIN, _GAmplitude);
return offsets;
}