// Temporary reference for the future realistic-water branch.
// Not included by any shader program.
//
// Normal-only adaptation of afl_ext's public-domain dragged exponential wave
// field. The Minecraft-style branch uses a lower-frequency six-band adaptation
// plus a very small per-block texture decorrelation term; this fuller version
// remains reserved for the future realistic-water branch.

vec3 ProceduralDraggedWaterNormalReference(
    vec3 geometricNormal,
    vec3 worldPosition,
    float animationTime,
    float exposureAmount,
    float waveScale,
    float waveSpeed,
    float waveStrength,
    int iterations
) {
    vec3 baseNormal = normalize(geometricNormal);
    float horizontalMask = smoothstep(0.65, 0.96, abs(baseNormal.y));
    float orientation = baseNormal.y >= 0.0 ? 1.0 : -1.0;
    vec2 position = worldPosition.xz * waveScale;
    float time = animationTime * waveSpeed;

    vec2 slope = vec2(0.0);
    float directionPhase = 0.0;
    float frequency = 8.0;
    float speed = 2.0;
    float weight = 1.0;
    float weightSum = 0.0;
    for (int waveIndex = 0; waveIndex < iterations; ++waveIndex) {
        vec2 direction = vec2(sin(directionPhase), cos(directionPhase));
        float phase = dot(position, direction) * frequency + time * speed;
        float exponentialWave = exp(sin(phase) - 1.0);
        float baseDerivative = exponentialWave * cos(phase);
        float footprint = fwidth(phase);
        float spectralWeight = 1.0 - smoothstep(0.55, 1.75, footprint);

        slope += direction * baseDerivative * frequency
               * weight * spectralWeight;
        weightSum += weight * spectralWeight;
        position -= direction * baseDerivative * weight * 0.058;
        directionPhase += 12.0;
        frequency *= 1.22;
        speed *= 1.07;
        weight *= 0.80;
    }

    slope /= max(weightSum, 1e-4);
    slope *= waveStrength * 0.32 * clamp(exposureAmount, 0.0, 1.0);
    vec3 waveNormal = normalize(vec3(-slope.x, 1.0, -slope.y))
                    * orientation;
    return normalize(mix(baseNormal, waveNormal, horizontalMask));
}
