Beispiel #1
0
    public static Vector3 GerstnerOffset4(Vector2 vxVtx, Vector4 steepness, Vector4 amp, Vector4 freq, Vector4 speed, Vector4 dirAB, Vector4 dirCD) {
        Vector3 offsets = Vector3.zero;

        Vector4 AB = Multiply(steepness.SwizzleXXYY(), amp.SwizzleXXYY(), dirAB);
        Vector4 CD = Multiply(steepness.SwizzleZZWW(), amp.SwizzleZZWW(), dirCD);

        Vector4 dotABCD = Multiply(
            freq,
            new Vector4(
                Vector2.Dot(dirAB.SwizzleXY(), vxVtx),
                Vector2.Dot(dirAB.SwizzleZW(), vxVtx),
                Vector2.Dot(dirAB.SwizzleXY(), vxVtx),
                Vector2.Dot(dirAB.SwizzleZW(), vxVtx)));

        Vector4 TIME = Time.timeSinceLevelLoad * speed;

        Vector4 COS = Cos(dotABCD + TIME);
        Vector4 SIN = Sin(dotABCD + TIME);

        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, amp);

        return offsets;
    }