20 - How to write a Height-Field Water Simulator with 100 lines of code.

  Рет қаралды 13,995

Ten Minute Physics

Ten Minute Physics

Жыл бұрын

In this tutorial I explain how to simulate water as a height field and its two-way interaction with solid objects.
The demo:
matthias-research.github.io/p...
For the source html code, demo and all other tutorials see matthias-research.github.io/p...
There is also a discord server to discuss all videos here: / discord

Пікірлер: 41
@quentinwach
@quentinwach Жыл бұрын
Oh boy, here we go again. Big fan here and I am really excited ^^ Thank you for all your work!
@j.j.maverick9252
@j.j.maverick9252 Жыл бұрын
Very impressed with how neatly you dealt with the submerged case!
@HansPeter-gx9ew
@HansPeter-gx9ew 10 ай бұрын
thank you Mr. Mueller, I cannot stress enough how valuable you explanations are, on the internet there are almost no sources available explaining this stuff at all. No book or paper I read explains the math really well. I would pay hundred of Euros to have a complete course that explains all the math, tricks and modern solutions used in CFD Papers to the point that I can implement it on my own. p.s. the more content =>the happier I get so thank you one more time :D
@therealpeter2267
@therealpeter2267 Жыл бұрын
Damn I coded almost the same thing for my procedural game like 7 years ago, the terrain was already using columns for caves and different materials, so adding water was mostly straight-forward. I was so surprised when adding velocity to it instead of just a heightmap resulted in waves 😄 it was so fun to play around with it aswell! :)
@williamchurch8401
@williamchurch8401 Жыл бұрын
Thank you for these tutorials! They have considerably helped me in implementing the techniques in your papers. xpbd is something I very much want to implement in my game. I would love to see tutorials expanding your soft body example with collisions with other soft bodies, rigid body shapes and particles. I have always thought there should be a physics system biased on simple particles and searching for such has lead me here. Your tutorials are a rare and prized thing! Thank you!
@Higgsinophysics
@Higgsinophysics Жыл бұрын
Man you are talented. Well done.
@PeteJonesF6
@PeteJonesF6 5 ай бұрын
Love all of your videos, they are simply awesome, thank you so much for taking the time :) I was just wondering if there is a very minor 'bug' in your code or not (its probably totally unnoticible in the result). Should you not be using an unmodified height when reading the neighbours to compute the velocities? There may be some slight errors introduced due to reading the positional damped height in directions which cell heights have been updated this frame (line 247-252).
@griffinschreiber6867
@griffinschreiber6867 9 ай бұрын
I love your videos! Since you seem to be focusing on fluids right now, maybe you would consider doing a video about smoothed particle hydrodynamics?
@cobaltxii
@cobaltxii Жыл бұрын
Very nice your videos are always great
@Madlion
@Madlion Жыл бұрын
Ur channel is gold!
@shihyuehjan3835
@shihyuehjan3835 Жыл бұрын
wow IT IS INSANE!
@euphrates5625
@euphrates5625 10 ай бұрын
Hello, do you also plan on a video on Rigid Body dynamics and shape matching? Your videos and your website simplifying intimidating concepts gave me courage to pursue more on computer graphics and simulations. You are doing sublime work!
@funorpain
@funorpain Жыл бұрын
Great demo! Can the next video simulate the movement of water in a swinging drinking glass?
@rlhugh
@rlhugh Жыл бұрын
Wow, that's so cool. I was like "How can you simulate 3d fluid in javascript???", and then you explain how. So clever :)
@rlhugh
@rlhugh Жыл бұрын
One trade-off with the way the influence of the balls on the water works is that moving the yellow ball along the bottom of the pool slightly causes huge waves directly above it. But on the other hand one doesn't have to render for several hours per second of output, so ... tradeoffs :)
@TenMinutePhysics
@TenMinutePhysics Жыл бұрын
Yes, that's true. Maybe making the effect dependent on the depth would help. I haven't tried that yet.
@94HellGate
@94HellGate Жыл бұрын
really nice. but something i have struggled with in the past is wave propagation speed. its heavily dependent on the grid resolution and there is no good way to adjust it to a realistic value
@atomictraveller
@atomictraveller Жыл бұрын
i dunno how far it will get you here, in audio/1d angular frequency is 2 * pi * hertz/samplerate insofar as angular frequency or w is the square root of k/ your spring constant for tuning mass-springs :)
@JensChristianRestemeier
@JensChristianRestemeier Жыл бұрын
Weird coincidence, as I'm looking at your other water papers at the moment. I've got the water from the old 2008 GDC paper working, and I'm looking at the shallow water paper from 2010 Siggraph. Did you ever write a newer version of that, or do you have an errata?
@johann2518
@johann2518 10 ай бұрын
Can this be used for slopes too, when tweeked right?
@plasid2
@plasid2 Жыл бұрын
Could you pls make tutorials series how make simulation from this article "Real-time Simulation of Large Bodies of Water with Small Scale Details" in Unreal Engine? I read this hundred time but still I dont know even how to start ;(
@VectorNodes
@VectorNodes Жыл бұрын
Another banger. Granted, it’s the worse fluid simulation lol but you even managed to make that good by rendering the surface. There’s an example of this sim on three js that I used while learning compute shaders and they just left that up to three
@TenMinutePhysics
@TenMinutePhysics Жыл бұрын
Yeah, the sim doesn't look very good :-) That is mostly due to fine tuning of the parameters and grid resolution. I haven't spent too much time on that. If you like, make it look better and send me an updated version.
@VectorNodes
@VectorNodes Жыл бұрын
@@TenMinutePhysics lol nooooo I hope you didn’t take it that YOUR sim didn’t look good. I mean the height field sim never looks good. I meant that yours is probably the only one I’ve liked
@TenMinutePhysics
@TenMinutePhysics Жыл бұрын
No worries. One can indeed make height field fluids look a lot better. This one is quite low res an overdamped
@erayavci3081
@erayavci3081 Жыл бұрын
How to make it interact with terrain?
@steffen7662
@steffen7662 Ай бұрын
I currently work on this, it's actually surprisingly easy
@Madlion
@Madlion Жыл бұрын
Is this also called Shallow Water simulation or is it something else?😊
@TenMinutePhysics
@TenMinutePhysics Жыл бұрын
The shallow water equations are a bit more sophisticated. I will make a tutorial about those too. They are more closely related to the Eulerian equations.
@Madlion
@Madlion Жыл бұрын
@@TenMinutePhysics oh ok, can I ask how physically accurate is this compared to shallow water? Like is this technique rooted in some physical model of water sim?
@MarcelNKemet
@MarcelNKemet Жыл бұрын
Very innovative way of doing fluid simulation. However it's mostly limited to visual effects with no real engineering applications (which breaks away from your previous tutorials). I wonder how you'd go about doing a Navier-stokes Fluid-structure simulation.
@user-og6hl6lv7p
@user-og6hl6lv7p 8 ай бұрын
Source code shows 695 lines, but granted a lot of that is unavoidable rendering stuff. Where specifically is the "100 lines" section though?
@444haluk
@444haluk Жыл бұрын
I don't understand why you prefer browser. I would think as an Nvidia researcher you would use Warp.
@rlhugh
@rlhugh Жыл бұрын
I'm going to guess it's using an NVidia GPU either way :)
@ivanalyoshafyodor
@ivanalyoshafyodor Жыл бұрын
I suspect the browser is accessible to a broader audience! It could also be seen as a testament to the code's performance.
@rlhugh
@rlhugh Жыл бұрын
Yeah, I can even run it on my phone, right.... and it runs at a reasonable speed. Super cool.
@SinanAkkoyun
@SinanAkkoyun Жыл бұрын
Would you as an assembly enthusiast write a production game in assembly? Writing all this in JS and with WebGL makes it super easy to get their hands on
@nolram
@nolram Жыл бұрын
So you can test out the demos directly! He does use WARP in his GPU simulation video.
@michaelkohlhaas4427
@michaelkohlhaas4427 9 ай бұрын
Could XPBD be used for modal analysis somehow?
Building and riding increasingly small bikes
18:01
Stuff Made Here
Рет қаралды 238 М.
Coding Adventure: Simulating Fluids
47:52
Sebastian Lague
Рет қаралды 1,7 МЛН
哈莉奎因以为小丑不爱她了#joker #cosplay #Harriet Quinn
00:22
佐助与鸣人
Рет қаралды 10 МЛН
Useful gadget for styling hair 🤩💖 #gadgets #hairstyle
00:20
FLIP FLOP Hacks
Рет қаралды 11 МЛН
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 68 МЛН
11 - Finding collisions among thousands of objects blazing fast
11:04
Ten Minute Physics
Рет қаралды 22 М.
17 - How to write an Eulerian fluid simulator with 200 lines of code.
12:05
Ten Minute Physics
Рет қаралды 290 М.
Why Does Diffusion Work Better than Auto-Regression?
20:18
Algorithmic Simplicity
Рет қаралды 263 М.
09 Getting ready to simulate the world with XPBD
15:38
Ten Minute Physics
Рет қаралды 20 М.
The BEST Way to Find a Random Point in a Circle | #SoME1 #3b1b
18:35
Gravity Visualized
9:58
apbiolghs
Рет қаралды 139 МЛН
The Boundary of Computation
12:59
Mutual Information
Рет қаралды 995 М.
What is the Smallest Possible .EXE?
17:57
Inkbox
Рет қаралды 343 М.
The Clever Way to Count Tanks - Numberphile
16:45
Numberphile
Рет қаралды 820 М.
16  - Simulation on the GPU
12:52
Ten Minute Physics
Рет қаралды 19 М.
Todos os modelos de smartphone
0:20
Spider Slack
Рет қаралды 67 МЛН
Как противодействовать FPV дронам
44:34
Стратег Диванного Легиона
Рет қаралды 140 М.
Как настроить камеру хоп-ап
1:00
TimToker
Рет қаралды 102 М.