Skip to content

Instantly share code, notes, and snippets.

@yorung
Last active October 6, 2017 14:11
Show Gist options
  • Save yorung/7e72ddd20e1318392b42fb9833a097c3 to your computer and use it in GitHub Desktop.
Save yorung/7e72ddd20e1318392b42fb9833a097c3 to your computer and use it in GitHub Desktop.
Make gerstner wave parameters
struct Wave
{
Vec2 dir;
float amplitude;
float waveLength;
};
struct ImmutableCB
{
Wave waves[100];
} cb;
for (int i = 0; i < dimof(cb.waves); i++)
{
Wave& w = cb.waves[i];
float randomRad = (float)(Random() * M_PI * 2 * 0.3f);
w.dir.x = sinf(randomRad);
w.dir.y = cosf(randomRad);
w.amplitude = 0.03f + powf(2.0f, (float)Random() * 2.0f) * 0.05f;
w.waveLength = 1.0f + powf(2.f, 1.f + (float)Random()) * 10.f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment