# OpenGL Water Waves Problem

I want to do a simple simulation of water drops producing waves in OpenGL with C/C++. I calculate height for each point of my plane grid in Vertex Shader with formula but it seems wrong at the beginning. I will atach a photo to ease the understanding: This is how the grid looks like at time = 0 (when the drop touched the water). The waves weren't generated only near the touch point and gradually advance. In the corners of the grid (and far from the touch point) there should be no change until a created wave approaches.

• That's expected to happen. – user3042253 Dec 20 '16 at 16:20

## 2 Answers

Try using a variable for amplitude (max height of wave). Pass it to shader. Vertex shader in your case. Multiply it to vertical component. (Some people use y-axis as vertical axis, while others use z-axis as vertical axis)

Initially set it to 0. When ball falls in fluid, set it to a value. And then multiply the that variable by constant less than 1 (for instance 0.97). Multiply it every frame. This will emulate decay.

Edit: for 's stated goal "In the corners of the grid (and far from the touch point) there should be no change until a created wave approaches."

Create a function such that

if 0 < r < attenuation distance then

Final height = amplitude variable (from above) * sqrt( power(x - ball.x,2) + power(y - ball.y,2)) / attenuation distance

If r > attenuation distance then height = 0

You could try to multiply the height by 0 outside the (increasing) radius of the 1st wave.