/*---------------------------------------------------------------------
    MakeUp Ultra Fast Water Waves (ported)
    ------------------------------------------------------------------
    Lightweight per-pixel water wave normal, ported/adapted from MakeUp
    Ultra Fast's normal_waves() function (shaders/lib/water.glsl),
    Copyright (C) javiergcim, licensed under LGPLv3
    (https://github.com/javiergcim/MakeUpUltraFast).

    Three noisetex samples at different world-space scale and scroll
    speed/direction are summed into a single fake bump-map offset. This
    is a pure texture-scroll animation (like Unbound's own original
    WATER_STYLE 2/3 default), NOT real geometric wave displacement like
    GERSTNER_WAVES - so it's noticeably cheaper per pixel (3 texture
    samples total vs. Gerstner's per-pixel wave summation), at the cost
    of looking a bit more "flat texture" up close and less physically
    correct at grazing angles. Meant as a third, fastest option
    alongside the existing texture-scroll default and GERSTNER_WAVES.

    Adapted to Unbound's own conventions:
      - Uses worldPos (playerPos + cameraPosition) instead of MakeUp's
        `worldposition` varying - same quantity, computed differently.
      - Speed is scaled by Unbound's WATER_SPEED_MULT slider instead of
        MakeUp's fixed 0.025 constant, so it responds to the same user
        setting as the other two wave styles.
      - Sample scale is divided by Unbound's WATER_SIZE_MULT slider for
        the same reason (MakeUp has no equivalent option).
---------------------------------------------------------------------*/
#ifdef MAKEUP_WATER_WAVES
    vec2 MakeupWaterWaveNormal(vec3 worldPos) {
        float speed = frameTimeCounter * 0.025 * WATER_SPEED_MULT;

        #if WATER_SIZE_MULT != 100
            #define WATER_SIZE_MULT_MK WATER_SIZE_MULT * 0.01
            vec2 wPos = worldPos.xz * WATER_SIZE_MULT_MK;
        #else
            vec2 wPos = worldPos.xz;
        #endif
        float wHeight = worldPos.y * 0.2;

        vec2 wave1 = texture2D(noisetex, ((wPos - wHeight) * 0.05) + vec2(speed, speed)).rg - 0.5;
        vec2 wave2 = texture2D(noisetex, ((wPos - wHeight) * 0.03125) - speed).rg - 0.5;
        vec2 wave3 = (texture2D(noisetex, ((wPos - wHeight) * 0.125) + vec2(speed, -speed)).rg - 0.5) * 0.66;

        return wave1 + wave2 + wave3;
    }
#endif
