I Made Ocean Waves and Buoyancy in Godot

Поділитися
Вставка
  • Опубліковано 30 лип 2021
  • Been playing Sea of Thieves a lot recently and really wanted to make some water physics, so I implemented some Gerstner/Trochoidal waves in Godot with a vertex shader and then simulated buoyancy in GDscript.
    Consider supporting the channel: / xen42
    Here's some of the resources I consulted while doing this.
    wikipedia lol
    developer.nvidia.com/gpugems/...
    catlikecoding.com/unity/tutor...
    Here's my messy code if you wanna look at it:
    github.com/xen-42/godot-waves...
    =========================================
    Credits for the sound effects used in the video:
    Beach Waves 04.wav freesound.org/people/Suburban...
    Car - seatbelt warning.wav freesound.org/people/soundmar...
    inception-sound-2.wav freesound.org/people/mikobunt...
    Music credits (in order):
    Monkeys Spinning Monkeys by Kevin MacLeod
    Link: incompetech.filmmusic.io/song...
    License: filmmusic.io/standard-license
    Wholesome by Kevin MacLeod
    Link: incompetech.filmmusic.io/song...
    License: filmmusic.io/standard-license
    Fluffing a Duck by Kevin MacLeod
    Link: incompetech.filmmusic.io/song...
    License: filmmusic.io/standard-license

КОМЕНТАРІ • 50

  • @nathanelrod2703
    @nathanelrod2703 2 роки тому +20

    I worked really hard for 2 months to create something like this. I got discouraged by the issue with estimating the waves and gave up. I love to see a tutorial or even just see your code to see how you over came some of the same issues I saw.
    Super impressive work.

    • @xen-42
      @xen-42  2 роки тому +2

      Cheers! I'll try to get a tutorial up as one of my next videos. There are a few more things I want to work out with the code before I share it, but I'll be sure to put it on github once I clean it up more and improve the wave height approximation

  • @SofiaStar1463
    @SofiaStar1463 2 роки тому +5

    Love how the boat spins into the air, like a ballerina , hahaha
    4:02

    • @xen-42
      @xen-42  2 роки тому +1

      It's very realistic!

    • @SofiaStar1463
      @SofiaStar1463 2 роки тому

      @@xen-42 yeah, I always have to be so careful not to get hit by those spinning boats when I'm at the beach! 🤣👍

  • @juliettegeo5002
    @juliettegeo5002 2 роки тому +5

    Thank you for the sea sickness warning very cool

    • @xen-42
      @xen-42  2 роки тому +1

      Ofc happy to help

  • @indieology7336
    @indieology7336 2 роки тому +1

    Awesome video!

    • @xen-42
      @xen-42  2 роки тому +1

      Glad you thought so!

  • @laky2k866
    @laky2k866 2 роки тому +6

    Nice video! Would be interesting to use this in for example the Minecraft Godot thing :D

    • @xen-42
      @xen-42  2 роки тому

      Definitely! I had considered it for this video but felt I should just focus more on the waves here

  • @jaws8621
    @jaws8621 2 роки тому +1

    Really funny and interesting, thanks.

    • @xen-42
      @xen-42  2 роки тому

      Thank you! I'm glad you enjoyed it

  • @forgeflarion8362
    @forgeflarion8362 2 роки тому +1

    Cool video

    • @xen-42
      @xen-42  2 роки тому +1

      Thank you!

  • @addmix
    @addmix Рік тому +3

    One thing I notice about a lot of games waves, (mainly Stormworks), when a wave comes over your vehicle or player, it only considers buoyancy forces, and ignores all fluid-velocity related forces.

    • @xen-42
      @xen-42  Рік тому

      Makes sense. I have no idea what the best way to do that would be

    • @addmix
      @addmix Рік тому

      @@xen-42 it would be an aerodynamic calculation on the buoyant objects, maybe I'll see about contributing to your waves project to add it.

    • @mariegrasmeier9499
      @mariegrasmeier9499 10 місяців тому

      Guess it does not need to be super accurate. If so: for cargo securing at sea ships, we usually assume 1kN per square meter for the impact force of sea sloshing. Maybe you can just use a fraction depending on wave height/wind speed and use 1kN for super bad weather.
      Just an idea to approximate it without boiling your computer

    • @addmix
      @addmix 10 місяців тому

      @@mariegrasmeier9499 well, it basically just turns into simple mass deflection aerodynamics.

  • @harrygeoffrion4520
    @harrygeoffrion4520 2 роки тому +3

    People calculating the Archimedes' principle: *stupid*
    Xen slapping some buoyant objects on the underside: *chad*

    • @industrialdonut7681
      @industrialdonut7681 2 роки тому

      archimedes wouldn't give a proper buoyancy *vector* that actually changes depending on the tilt of the ship in the water and such though, it's simply the magnitude of the buoyancy on an object

  • @marc.lepage
    @marc.lepage Рік тому

    Sweet.

  • @theM4R4T
    @theM4R4T 2 роки тому

    Was trying to make the same thing. The fact that the shader can't interact with objects and vice versa is frustrating, cause to make an immersive ocean there need to be variable wave height and speed and wind direction.

    • @xen-42
      @xen-42  2 роки тому

      Yeah it's pretty annoying, you just have to have the same algorithm running in two places and just make sure it stays synced

  • @zareth1226
    @zareth1226 2 роки тому +1

    When they say you will never use maths irl

    • @xen-42
      @xen-42  2 роки тому

      a^2 + b^2 = c^2

  • @giantfrogstudios839
    @giantfrogstudios839 Рік тому +1

    How do you prevent the waves from washing through the boat like that?

    • @xen-42
      @xen-42  Рік тому

      They do actually wash through unfortunately, the ship just isn't very deep and follows the waves well enough that you don't really see it. You have to do weird shader stuff to actually prevent the waves showing inside

  • @AnKlMa
    @AnKlMa 2 роки тому +1

    Will you still be uploading a tutorial on this by any chance?

    • @xen-42
      @xen-42  Рік тому +1

      Thanks for reminding me, I really need to get around to it. I'm just not 100% happy with the buoyancy code because its technically slightly off (altho not really noticeable) but I haven't taken the time to find a better way to do it.

  • @mariegrasmeier9499
    @mariegrasmeier9499 10 місяців тому

    Tried this in unity 3d. It worked until I used it on a big ship. Started flying and spinning.
    Will think about the global/local thing you mentioned and try again.
    Thank you so much for the hint

    • @xen-42
      @xen-42  10 місяців тому

      Hope it ends up being helpful!

  • @extremehyperventilation4377
    @extremehyperventilation4377 2 роки тому +3

    Did you use spatial nodes for buoyancy?

    • @xen-42
      @xen-42  2 роки тому

      Yep, and had them be children of a rigid body. In the spatial noise process function I'd check if they were below the wave height and then add a force to the parent rigid body at the position of the spatial noise

  • @rickland1810
    @rickland1810 2 роки тому +1

    Amazing work.
    Could you please share your code? I'm trying to do something similar and I'm struggling with the shader.

    • @xen-42
      @xen-42  2 роки тому +1

      Here you go, will also update the description to link it: github.com/xen-42/godot-waves-buoyancy

    • @rickland1810
      @rickland1810 2 роки тому

      @@xen-42 Thanks!

  • @randomboy2004
    @randomboy2004 2 роки тому +1

    Hey can you continue minecraft godot : but this time you add cave system . Not just any cave but actual cave with eco system kinda stuff

    • @xen-42
      @xen-42  2 роки тому

      I might do a cave video some day. What do you mean by with an eco system?

    • @randomboy2004
      @randomboy2004 2 роки тому

      @@xen-42 sorry i meant improved like big cave instead of looking like "drilling the chunk" and called it cave

  • @ghowstcrafter9201
    @ghowstcrafter9201 2 роки тому +3

    pls give source code

    • @xen-42
      @xen-42  2 роки тому +2

      I will once I am able to rewrite it to make it better and clearer

  • @waporwave5066
    @waporwave5066 Рік тому +1

    Global coordinates?!?! "world coord offset"?!?! IT TAKES A LOCAL COORDINATE
    AND YOUR TAKING FOREVER TO FIND THAT OUT MADE ME TAKE FOREVER TO FIND IT OUT THAT YOU WERE WRONG!!!!!!!

    • @xen-42
      @xen-42  Рік тому +1

      big mood

    • @waporwave5066
      @waporwave5066 Рік тому

      @@xen-42 i have formally apoligize, apparently it's the rotation that's in global coordinates 😔😔and this took me forever to find out too😔😔😔 you could have been more clear tho

    • @xen-42
      @xen-42  Рік тому

      sry