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

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • In this tutorial I explain how to simulate water as a height field and its two-way interaction with solid objects.
    The demo:
    matthias-resea...
    For the source html code, demo and all other tutorials see matthias-resea...
    There is also a discord server to discuss all videos here: / discord

Комментарии • 41

  • @PeteJonesF6
    @PeteJonesF6 6 месяцев назад +2

    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).

  • @therealpeter2267
    @therealpeter2267 Год назад +5

    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! :)

  • @griffinschreiber6867
    @griffinschreiber6867 11 месяцев назад +2

    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?

  • @Higgsinophysics
    @Higgsinophysics Год назад +2

    Man you are talented. Well done.

  • @quentinwach
    @quentinwach Год назад +2

    Oh boy, here we go again. Big fan here and I am really excited ^^ Thank you for all your work!

  • @johann2518
    @johann2518 Год назад +1

    Can this be used for slopes too, when tweeked right?

  • @j.j.maverick9252
    @j.j.maverick9252 Год назад +1

    Very impressed with how neatly you dealt with the submerged case!

  • @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 ;(

  • @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?

  • @94HellGate
    @94HellGate Год назад +1

    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 :)

  • @HansPeter-gx9ew
    @HansPeter-gx9ew Год назад

    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

  • @euphrates5625
    @euphrates5625 Год назад

    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!

  • @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!

  • @michaelkohlhaas4427
    @michaelkohlhaas4427 11 месяцев назад

    Could XPBD be used for modal analysis somehow?

  • @funorpain
    @funorpain Год назад

    Great demo! Can the next video simulate the movement of water in a swinging drinking glass?

  • @cobaltxii
    @cobaltxii Год назад

    Very nice your videos are always great

  • @Madlion
    @Madlion Год назад

    Ur channel is gold!

  • @shihyuehjan3835
    @shihyuehjan3835 Год назад

    wow IT IS INSANE!

  • @Madlion
    @Madlion Год назад

    Is this also called Shallow Water simulation or is it something else?😊

    • @TenMinutePhysics
      @TenMinutePhysics  Год назад +1

      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?

  • @erayavci3081
    @erayavci3081 Год назад

    How to make it interact with terrain?

    • @steffen7662
      @steffen7662 3 месяца назад

      I currently work on this, it's actually surprisingly easy

  • @MarcelNKemet
    @MarcelNKemet Год назад +4

    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.

  • @rlhugh
    @rlhugh Год назад +1

    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  Год назад +2

      Yes, that's true. Maybe making the effect dependent on the depth would help. I haven't tried that yet.

  • @VectorNodes
    @VectorNodes Год назад +1

    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  Год назад +2

      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 Год назад +1

      @@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  Год назад +2

      No worries. One can indeed make height field fluids look a lot better. This one is quite low res an overdamped

  • @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 :)

  • @user-og6hl6lv7p
    @user-og6hl6lv7p 9 месяцев назад

    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 Год назад +1

      I'm going to guess it's using an NVidia GPU either way :)

    • @ivanalyoshafyodor
      @ivanalyoshafyodor Год назад +12

      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 Год назад +2

      Yeah, I can even run it on my phone, right.... and it runs at a reasonable speed. Super cool.

    • @SinanAkkoyun
      @SinanAkkoyun Год назад +3

      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 Год назад +2

      So you can test out the demos directly! He does use WARP in his GPU simulation video.