diff --git a/shaders/surface.vert b/shaders/surface.vert index c855b14abbb4c42dd58fe144879581eb54bc6595..a7e5ff88a5a492a53bf64aab03e474ec9ad3c76e 100644 --- a/shaders/surface.vert +++ b/shaders/surface.vert @@ -24,7 +24,7 @@ struct Wave { }; layout(std140) uniform WaveBuffer { - Wave waves[16]; + Wave waves[64]; }; /* Get the offset for a single wave along the y-axis. */ @@ -41,7 +41,7 @@ float get_gerstner_xz(Wave wave, float dir, float x, float z, float t) { // float w = 2.0/wave.L; float w = sqrt(g*(2*pi/wave.L)); float phase_const = wave.S * w; - float Q = 0.3/(w*wave.A*in_WavesNum); + float Q = 0.8/(w*wave.A*in_WavesNum); return Q * wave.A * dir * cos(dot(normalize(wave.D) * w, vec2(x, z)) + t * phase_const); } @@ -74,8 +74,7 @@ vec3 compute_normal(vec3 pos, float t) { float offset_z = (get_waves(offset1, t) - get_waves(offset2, t)).z; // Construct the normal using partial derivatives - float scale = 20.0; // TODO: Not here - return normalize(vec3(-offset_x * scale, 1.0, -offset_z * scale)); + return normalize(vec3(-offset_x, 1.0, -offset_z)); } void main(void) diff --git a/src/main.cpp b/src/main.cpp index 72f1b11d2f5add71e3f6dfbbaa7878090110e5bd..4da357a0f987d799f0ef96070fa8005e626d4b93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,8 +38,8 @@ struct Surface : public Object { char const* UNIFORM_BLOCK = "WaveBuffer"; static int const MAX_WAVES {16}; static constexpr float const MEDIAN_WAVELENGTH {2.6}; - static constexpr float const MEDIAN_AMPLITUDE {0.002}; - static constexpr float const MEDIAN_SPEED {0.3}; + static constexpr float const MEDIAN_AMPLITUDE {0.006}; + static constexpr float const MEDIAN_SPEED {0.6}; static constexpr float const MEDIAN_DIR {3.14/4.0}; struct Wave { @@ -56,7 +56,7 @@ struct Surface : public Object { std::vector<Wave> waves {}; // Direction of the wind [0-2π] - float wind_dir {3.14/3.0}; + float wind_dir {0.0}; Surface() = default; @@ -86,7 +86,7 @@ struct Surface : public Object { rd_amplitude(rd), rd_speed(rd), {}, - vec2(cos(dir), sin(dir)) + vec2(cos(dir), sin(dir)), }; }