float getWaterHeight(in vec3 rpos, const bool isPOM) {
    float windAnim = -frameTimeCounter*25.0;
    vec2 windTemp = vec2(windAnim, 0.0);
    vec3 wind = vec3(windTemp.x, 0.5*windAnim, windTemp.y);

    #ifdef isGbuffer
        if (ice == 1) windTemp = vec2(0.0);
    #endif

    rpos *= 20.0;

    rpos.y *= 0.2;

    float noise     = worley2D(rpos.xz+rpos.y, 1.0, windTemp)*2.0-1.0;
        noise      += worley2D(rpos.xz+rpos.y, 1.33, -windTemp)-0.5;
        noise      += worley2D(rpos.xz+rpos.y, 2.24, windTemp.yx)*0.5-0.25;

    #ifdef isGbuffer
        float multi     = saturate((-dot(normalize(scene.normal), normalize(pos.screen)))*8.0)/sqrt(sqrt(max(vertexDist, 4.0)));
    #else
        float multi = 1.0;
    #endif


    #ifdef isCaustic
        return (1.0-noise);
    #else
        return noise*multi;
    #endif
}
float getWaterHeight(in vec3 rpos) {
    return getWaterHeight(rpos, false);
}