diff --git a/src/surface.cpp b/src/surface.cpp index 9df776bf5cd0f4ca32d184ef5888a99cfd4b7b18..268b767977fc94bc3134f328d5f9c5d4c8d7fc46 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -4,24 +4,24 @@ #include <random> -Surface::Wave Surface::get_wave() const { +Surface::Wave Surface::get_wave(float const w, float const a, float const s, float const d) const { std::random_device rd; std::mt19937 gen(rd()); std::uniform_real_distribution<float> rd_wavelength( - 0.5 * MEDIAN_WAVELENGTH, 2 * MEDIAN_WAVELENGTH + 0.5 * w, 2 * w ); std::uniform_real_distribution<float> rd_amplitude( - 0.5 * MEDIAN_AMPLITUDE, 2 * MEDIAN_AMPLITUDE + 0.5 * a, 2 * a ); std::uniform_real_distribution<float> rd_speed( - 0.5 * MEDIAN_SPEED, 2 * MEDIAN_SPEED + 0.5 * s, 2 * s ); std::uniform_real_distribution<float> rd_dir( - wind_dir - MEDIAN_DIR, wind_dir + MEDIAN_DIR + wind_dir - d, wind_dir + d ); float const dir {rd_dir(rd)}; @@ -55,8 +55,22 @@ Surface::Surface(Model* model, GLuint program) // // Link the UBO to the shader’s uniform block glUniformBlockBinding(program, block_index, BINDING_POINT); - for (int i = 0; i < MAX_WAVES; i++) { - waves.push_back(get_wave()); + for (int i = 0; i < MAX_WAVES - 16; i++) { + waves.push_back(get_wave( + MEDIAN_WAVELENGTH, + MEDIAN_AMPLITUDE, + MEDIAN_SPEED, + MEDIAN_DIR + )); + } + + for (int i = 0; i < 16; i++) { + waves.push_back(get_wave( + 0.1, + 0.0015, + MEDIAN_SPEED, + 3.14 + )); } // Bind the buffer before updating it. diff --git a/src/surface.h b/src/surface.h index f4cfd79fcf3b9a9b4f5dbc767b05c4d67fadfee2..69d01ea745d5bec92d0fc05f735d9cbde6db58c3 100644 --- a/src/surface.h +++ b/src/surface.h @@ -15,9 +15,9 @@ public: static GLuint const BINDING_POINT {1}; static constexpr const char * UNIFORM_BLOCK = "WaveBuffer"; private: - static int const MAX_WAVES {16}; - static constexpr float const MEDIAN_WAVELENGTH {1.0}; - static constexpr float const MEDIAN_AMPLITUDE {0.003}; + static int const MAX_WAVES {32}; + static constexpr float const MEDIAN_WAVELENGTH {5.0}; + static constexpr float const MEDIAN_AMPLITUDE {0.008}; static constexpr float const MEDIAN_SPEED {0.2}; static constexpr float const MEDIAN_DIR {3.14/2.0}; @@ -35,6 +35,6 @@ private: std::vector<Wave> waves {}; float wind_dir {0.0}; // Direction of the wind [0-2π] - Wave get_wave() const; + Wave get_wave(float const w, float const a, float const s, float const d) const; };