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
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.
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
Love how the boat spins into the air, like a ballerina , hahaha
4:02
It's very realistic!
@@xen-42 yeah, I always have to be so careful not to get hit by those spinning boats when I'm at the beach! 🤣👍
Thank you for the sea sickness warning very cool
Ofc happy to help
Awesome video!
Glad you thought so!
Nice video! Would be interesting to use this in for example the Minecraft Godot thing :D
Definitely! I had considered it for this video but felt I should just focus more on the waves here
Really funny and interesting, thanks.
Thank you! I'm glad you enjoyed it
Cool video
Thank you!
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.
Makes sense. I have no idea what the best way to do that would be
@@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.
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
@@mariegrasmeier9499 well, it basically just turns into simple mass deflection aerodynamics.
People calculating the Archimedes' principle: *stupid*
Xen slapping some buoyant objects on the underside: *chad*
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
Sweet.
Thank you!
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.
Yeah it's pretty annoying, you just have to have the same algorithm running in two places and just make sure it stays synced
When they say you will never use maths irl
a^2 + b^2 = c^2
How do you prevent the waves from washing through the boat like that?
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
Will you still be uploading a tutorial on this by any chance?
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.
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
Hope it ends up being helpful!
Did you use spatial nodes for buoyancy?
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
Amazing work.
Could you please share your code? I'm trying to do something similar and I'm struggling with the shader.
Here you go, will also update the description to link it: github.com/xen-42/godot-waves-buoyancy
@@xen-42 Thanks!
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
I might do a cave video some day. What do you mean by with an eco system?
@@xen-42 sorry i meant improved like big cave instead of looking like "drilling the chunk" and called it cave
pls give source code
I will once I am able to rewrite it to make it better and clearer
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!!!!!!!
big mood
@@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
sry