# Custom Water Waves Simulation

https://www.roblox.com/games/5017072373/Custom-Realistic-Water-Simulator

I wanted to create some realistic water waves and this is what I produced. The place lets you play with it. This was a challenge to get running fast so it took quite a bit of optimisation. There’s also some fancy physics that occur in the place such as waves pushing you (done via code) and wave noises based on their relative position to you. For anyone interested, this involves using the wave equation (and extra methods to make it work on a computer).

This is dynamic and not something animated via keyframes. For e.g. you can collide several waves with eachother to cancel them out.

For reference, a simple explanation of how it works (without talking about how I got the wedges to triangulate the surface), imagine a grid of 70 x 70 points. Imagine each point is connected in a lattice-like structure to each adjacent point by a spring constraint (and a prismatic constraint so that they can only slide up/down). Whilst this doesn’t actually use spring constraints, it works fairly similar. The points hold themselves together with these “springs” and will exhibit wave-like motion when pulled up or down.

E.g. this uses no code and produces the same effect with only constraints.

43 Likes

it looks cool… Hey, I think it is a good thing to post a reply about your creation.

So… if you interested go ahead I love some cool thing about the people that were doing in the studio and also pretty cool water
but then i found some issue with your water wave simulation…
here the picture of it:

it happen when you low everything on the manual of the “water wave simulation” to 0 it will cost the water look like spike!!!
So i hope you fix this soon…
that all for now and I will see you in the next reply…
Seeya!

4 Likes

I left that in there intentionally to let users create really tall waves if they wanted. Speeds slightly above avoid that bug. If you want waves on the minimum speed, you need to make sure all the fast moving waves are flattened out (increasing viscosity), then slow down everything to 0.01, then finally, add in your waves on that speed by clicking them in.

2 Likes

This looks very cool and this could be used beautifully in low-poly games, great job!

1 Like

Thanks! Would be great if it could be used in an actual game but its too laggy / uses a lot of wedges to hold the surface.
Improved the physics code to be slightly more smooth.

Wow that looks super cool. Are you considering making it open source?

1 Like

Yes, I will soon make this open source

1 Like

that would be cool if you do that, I have tons of ides on things to add and take away, this systems is really cool. good job

It’s now open source. Enjoy!
Place now allows copying.

1 Like

ah cool, before I take a peek at the code and start messing with it, can you explain the math?

1 Like

CodelessCustomWater.rbxl (31.4 KB)
Hit play and unanchor the model.

So I decided to make a demonstration of my custom water using only constraints. This uses no code whatsoever. Thought this was really cool.

The idea is that you can model the surface of a material as joined up by several molecules in a lattice like structure. Each molecule wants to stay near other molecules and so will pull eachother together if stretched apart. A good model of this is to connect them up with springs.

Anywho, the idea is that the wave equation simplifies having hundreds of springs into a single equation. I then apply my own physics solver via code.

Lastly, for optimization, I “squeeze” a 70x70 grid into a `23x23 grid = 529 grid cells = 529*(4 wedges per grid cell) = 2116 wedges.`

6 Likes

Hi there, seems like you’ve made this simulation open-sourced at one point. Is it possible if it gets open-sourced once again? (the old non-skinned version is fine for me), I’m just interested to read through your physics and code to learn deeper about the wave equations. I’m aware of the Gerstner (trochoidal) waves which others commonly use, but it just doesn’t really give me the effect that I’m really looking for.

Thank you!

soz for necro

5 Likes