Ocean waves simulation with Fast Fourier transform

Sdílet
Vložit
  • čas přidán 19. 05. 2024
  • How does ocean waves simulation with Fast Fourier transform work?
    Source code:
    github.com/gasgiant/FFT-Ocean
    Music:
    / igor_vaiman
    Catlike Coding on Gerstner waves:
    catlikecoding.com/unity/tutor...
    3Blue1Brown on Euler's formula:
    • e^(iπ) in 3.14 minutes...
    3Blue1Brown on Fourier transform:
    • But what is the Fourie...
    References:
    github.com/gasgiant/FFT-Ocean...
    0:00 Intro
    1:02 Waves Math
    2:52 Fast Fourier Transform
    5:36 Oceanographic Spectra
    9:24 Algorithm Walkthrough
    11:04 Cascades
    12:25 Height Sampling
    13:53 Outro
    #unity #shaders #water
  • Hry

Komentáře • 327

  • @peterhall6656
    @peterhall6656 Před 2 lety +334

    You have done some good work on this issue. I am a retired expert in Fourier theory and it is interesting to see how the FFT still rocks on 50 years ago when I first used it.

    • @warpigs330
      @warpigs330 Před 2 lety +33

      something tells me that we will be using fft for as long as we do computing. It is so fundamental.

    • @ShatabdaRoy115
      @ShatabdaRoy115 Před 2 lety +19

      holy moly. I'm 14 and I got alot to learn

    • @Francesco_Armillotta
      @Francesco_Armillotta Před 2 lety +13

      Basically you can study whatever field in physics and fourier theorem is everywhere :)

    • @zacharychristy8928
      @zacharychristy8928 Před 2 lety +7

      I remember learning about it for the first time, and it totally changed how I thought about information. I used them like crazy in my next internship on software-defined radar systems. They're an insanely good tool to have.

    • @Nekuzir
      @Nekuzir Před 2 lety +3

      @@ShatabdaRoy115 the e^2pi*i part is really just the number 1
      e^pi*i is negative 1
      e^(angle in radians)*i is the number on the complex unit circle distance 1 from the origin at the angle you put in

  • @phillipjoyce8825
    @phillipjoyce8825 Před 3 lety +304

    Got about 7 minutes in until my brain rejected it. Stunning work, good on you for being so good at maths! I wish I could understand what you've done properly

    • @dennisyurchenko7311
      @dennisyurchenko7311 Před 3 lety +8

      I made it about 6 mins i guess im more smooth brained lol

    • @RomekRJM
      @RomekRJM Před 2 lety +40

      I feel this video is too condensed. There are multiple complicated math formulas appearing on the screen in 2-3s intervals at some point. It is certainly a good glimpse for someone looking for high level overview on how to generate oceanic waves, but to cover it completely clip would have to be 2h+. Kudos for making it though!

    • @RileyGein
      @RileyGein Před 2 lety +4

      @@RomekRJM the linked videos in the description help make a bit more sense of it. Not that it helped me much; I’m absolute garbage at math

    • @santosmichelena3519
      @santosmichelena3519 Před 2 lety +9

      I understood everything quite clearly but I think it's only because I and doing my masters in a very very closely related topic. The video is definitely very dense.

    • @vladislavkornushenko
      @vladislavkornushenko Před 2 lety +4

      well done, for me 4 min was enough)

  • @papel6280
    @papel6280 Před 2 lety +112

    Can’t believe I am learning Physics in a Unity tutorial-this is so well-made!

    • @gamedevwithjacquelynnehei465
      @gamedevwithjacquelynnehei465 Před 2 lety +10

      I totally get what you mean! It's crazy how much math and science you use in game development. Watching videos like this just shows me how much I don't know.

    • @damislav
      @damislav Před rokem +4

      @@gamedevwithjacquelynnehei465 if one would know that math and physics can actually be fun and used for something, maybe I would bother to learn it in school xD

    • @TheArrowster
      @TheArrowster Před 10 měsíci +2

      ​@@gamedevwithjacquelynnehei465 Computers are all about math and science. Virtual environment is just a simplified version of real world.

  • @NicholasSpies
    @NicholasSpies Před 2 lety +71

    I was at a computer graphics company (on of the first doing commercial work) in 1987 and saw what was at the time an astounding, color still of a perspective view of the surface of a calm sea, bathed in the golden light of a sunset. It had taken hours, perhaps even over night, to render on a minicomputer. It was quite advanced at the time.
    I was told by the guy who modeled the scene that it involved sin/cos functions, which was more or less obvious because it was periodic but I didn't really understand how (and the source was FORTRAN, which had to be batch processed from a stack of Hollerith [IBM ]cards). So it was a pleasure to find this explanation.

  • @flatspinrc5262
    @flatspinrc5262 Před 2 lety +32

    Hope there's more videos coming! They are all beautifully presented.

  • @ltmcolen
    @ltmcolen Před 2 lety +47

    I've personally had instances when we were at anchor,
    the current came from the north and was stronger than the wind coming from the south.
    Pushing the ship with her stern towards the wind. The strangest part was that the waves also came from the south
    hitting the transom. It's like a huge bass drum being kicked irregularly

  • @badradish2116
    @badradish2116 Před 2 lety +4

    THIS IS GREAT. THANK YOU!!
    its so hard to find detailed breakdowns of complex topics that arent targeted to specialists or total beginners. 100% sub'd and excited to see what else you have to offer! THANKS AGAIN.

  • @redsteph
    @redsteph Před 2 lety +50

    This is awesome, hope you’ll cover ocean shading, LOD management etc as you’ve said!

  • @joshko9030
    @joshko9030 Před 3 lety +30

    Amazing work man! Getting the feeling that this is gonna blow up

  • @derp4581
    @derp4581 Před 3 lety +3

    Man, youtube recommendations have been awesome lately! Finding all of these small but amazing channels left and right

  • @tiporari
    @tiporari Před 2 lety +19

    I implemented your GitHub code in a unity project with XR enabled. These waves look awesome in VR. I assumed performance would be an issue, but it runs perfectly. Thanks for creating this. Giving me an awesome jumping off point for a novel VR experience.

    • @FarhadHakimov
      @FarhadHakimov Před 2 lety +4

      Oh, thanks for the idea! I was hoping to implement it in Unreal, but VR in addition to ocean would be great. Here's hoping I won't get seasick xP

  • @superman39756
    @superman39756 Před 9 měsíci

    What a great video! Thank you for going into the details and providing detailed references.

  • @curiouspers
    @curiouspers Před 2 lety +7

    This is very high quality content, thank you! I hope you're doing great and will return with more great stuff!

  • @marshallross3373
    @marshallross3373 Před 2 lety +3

    Great video! Thanks for covering the math and describing the issues involved.

  • @neuralworknet
    @neuralworknet Před 7 měsíci

    Omg this channel is insane! I really loved your videos. Keep up man!

  • @wii3willRule
    @wii3willRule Před 2 lety +10

    Man, this is awesome. A bit dense/condensed, but an excellent high level overview-- I learned a lot. I'm completely new to FFT, so I know that I'm going to be checking out the 3B1B video next, but this was honestly the coolest introduction.

  • @maki4041
    @maki4041 Před rokem +1

    this video is just awesome.And I am really interested in topics the current video does not mention like ocean shader and mesh LOD.Looking forward to see more about these!

  • @user-rj7kg6jj7k
    @user-rj7kg6jj7k Před 8 měsíci +2

    Очень интересно !

  • @norbertpape1993
    @norbertpape1993 Před 8 měsíci

    Beautiful work!

  • @dariocardajoli6831
    @dariocardajoli6831 Před 2 lety

    Outstanding work . Speechless but still commenting seeing how underrated this vid is .

  • @danielprovder
    @danielprovder Před 2 lety +2

    Im not sure the accuracy of this, but I’ve read that there is something about pink noise as the spectrum of the ocean, it has a characteristic rise in amplitude as the frequency decreases. What’s interesting is that the pink noise is invariant under Fourier transform, and I wonder if applying this randomness instead of Gaussian would change the already beautiful results. Looking forward to more content!

  • @Ahivo
    @Ahivo Před 2 lety +1

    Never thought fourier transforms would work for me one day
    Dude the world is a better place with u in it
    So you could help people understand better and more tangible
    Great job
    Keep up the good work

  • @roisanggung951
    @roisanggung951 Před 2 lety

    What a very outstanding explanation, i love your work!

  • @GlorifiedPig
    @GlorifiedPig Před 3 lety +1

    wow this looks ultra realistic, good job!

  • @adampy96
    @adampy96 Před 3 lety

    Subscribed, you deserve more attention on youtube. Thanks for that video!

  • @tolkienfan1972
    @tolkienfan1972 Před 9 měsíci

    Fantastic! Wish I saw this earlier

  • @farechildd
    @farechildd Před 2 lety +4

    Pretty cool to see the applications of what you learn in differential equations

    • @stdcall
      @stdcall Před rokem

      if you do anything even mildly related to math/physics/computation in the future it will all be diffy qs

  • @anglewyrm3849
    @anglewyrm3849 Před 2 lety +3

    I once worked on a lobster fishing boat 90 miles off the coast of North Carolina, and there were rare occasions where the ocean was amazingly flat, as depicted in this simulation. But most of the time there were rolling hills and even mountains of water.

    • @JumpTrajectory
      @JumpTrajectory  Před 2 lety +2

      Thank you for the observation! This is swell, I think. I didn't know how important it is for the look of the ocean at the time as I was making the video, but now I understand that it is present most of the time. Good news is that it is already supported in the code, I just didn't include in the scenes for the video.

  • @DaveJ6515
    @DaveJ6515 Před 8 měsíci

    When something conceptually and mathematically so elegant works so well for so long in so many different fields, it probably holds some fundamental meaning.

  • @AlanZucconi
    @AlanZucconi Před 9 měsíci

    This is the content I'm here for! 👏

  • @loganlee7510
    @loganlee7510 Před 2 měsíci

    Very easy to understand :)
    Thank you for making this video

  • @EnginAtik
    @EnginAtik Před 9 měsíci

    Very nice work! I thought the foam was a bit much on some of the waves. They gave the impression that they were hitting some rocks that were out of the frame. Then again there must be an indication of reflected waves if it was the case which I did not notice. It's amazing how we get attuned to how the sea behaves: our vestibular system starts doing some Fourier analysis after spending some time on the see and we get sea legs when we are back on land.

  • @williamriddle9910
    @williamriddle9910 Před 2 lety

    Great topic and extremely detailed, such great work nice!

  • @abhishek.g0yal
    @abhishek.g0yal Před 3 lety

    Awesome 🔥🔥🔥
    Instantly attention captured

  • @tupaicindjeke275
    @tupaicindjeke275 Před 2 lety

    Dude. Your video is great. Keep up the good work.

  • @apurbabiswas7218
    @apurbabiswas7218 Před 3 lety +2

    This is amazing work - I'll be looking out for a Patreon page soon. I hope you keep making videos - subscribed!

  • @papaysailor1017
    @papaysailor1017 Před 3 lety

    This is so cool... I've gotta try this method in my Archipelago project! Thank you for posting!

  • @zetathix
    @zetathix Před rokem

    Thank you for good knowledge, I will try to digest it into use.

  • @sovietdolphin
    @sovietdolphin Před rokem

    Great explenation and visualisation!

  • @soheil4471
    @soheil4471 Před 3 lety

    nice job man keep going amazing content!

  • @anjoomfaisal
    @anjoomfaisal Před 10 měsíci

    This is so interesting. People like you make games beautiful. Thank you :)

  • @therollo9
    @therollo9 Před 8 měsíci +3

    Who’s here from the Acerola ocean video?

  • @mauritsgli
    @mauritsgli Před 3 lety

    Fantastic work, thank you

  • @galabolatory4905
    @galabolatory4905 Před 3 lety +1

    좋은 강의 영상입니다! 많은 도움이 되었습니다~! 정말 감사합니다.

  • @migram4190
    @migram4190 Před 2 lety

    Beautiful presentation. Subbed!

  • @mooseriderwpg9586
    @mooseriderwpg9586 Před 2 lety +1

    Maaaan CZcams always recommends videos explaining the gap in your understanding for an exam perfectly right after the exam XD

  • @nesslange1833
    @nesslange1833 Před 2 lety +1

    What a genius applying these advanced transforming things. Only thing you could have added is clouds /sky movement to make it even more vivid.

  • @mrocean1293
    @mrocean1293 Před 2 lety

    Super useful and very nicely done!

  • @mrcao-fb9wx
    @mrcao-fb9wx Před 2 lety

    One of the best video on the topic!

  • @TwistedPresence
    @TwistedPresence Před 2 lety

    Excellent video! Great job.

  • @erikm9768
    @erikm9768 Před 2 lety +1

    Huge like to this , great explanation! bravo!

  • @whidzee
    @whidzee Před 3 lety +8

    Wow this is just amazing. most of the description went over my head but i am still very impressed. How would you go about combining this with onshore waves around an island? to have breaking waves coming from all angles?

    • @JumpTrajectory
      @JumpTrajectory  Před 3 lety +6

      Oh! That's a whole other thing! I've read some about it, but not much. Check outh this talk developer.download.nvidia.com/assets/gameworks/downloads/regular/events/cgdc15/CGDC2015_ocean_simulation_en.pdf

    • @stevethewolf562
      @stevethewolf562 Před 2 lety +2

      @@JumpTrajectory You should definitely make a video about this also, it's super interesting and probably more useful to a wider variety of devs. Great work so far, by the way!

  • @stephencarlson6297
    @stephencarlson6297 Před 2 lety

    This is superb! Definitely subscribing!

  • @hugo5097
    @hugo5097 Před 3 lety +2

    Your videos are honestly amazing! Thank you and keep it up!

  • @Happen2Bme
    @Happen2Bme Před 2 lety

    Thanks for the knowledge.

  • @radcliffe2192
    @radcliffe2192 Před 3 lety +2

    Очень круто! Спасибо, что решил поделиться.

  • @romanb2770
    @romanb2770 Před 2 lety

    Subbed, very nicely presented overview

  • @Drogny
    @Drogny Před 2 lety

    Really interesting and well made!!

  • @BloedQS
    @BloedQS Před rokem

    It's great work. Thank you!

  • @TopConductor
    @TopConductor Před 4 měsíci

    Dude, you are legend!

  • @pyrit3863
    @pyrit3863 Před měsícem

    Looked at the code and have no idea what half the stuff does but I understand the concept. Really high quality waves though, looks amazing.

  • @josephseed9270
    @josephseed9270 Před 2 lety

    dude you really deserve millions of subscribers

  • @tefilobraga
    @tefilobraga Před 2 lety +3

    Excellent and fascinating work. It is very neat how you can synthesize a realistically-looking ocean based on rigorous physics of wave dynamics. I have one comment regarding the rendering, for example at 11:05. While the theory used is certainly for non-breaking waves, and therefore the waves by themselves would not produce foam, one can easily imagine a situation where the foam is pre-existing and the waves just move it around. Now, what happens in this animation extract is that the white patches (which I perceive as foam) move with the wave crests. In my opinion, you would get a more realistic effect if the foam remained on the air-water interface essentially at the same points in space horizontally, and the waves simply propagated over it. If you want to be maximally realistic, you could consider the back and forth motion associated with the horizontal oscillations produced by each wave cycle, and even, possibly, the slow drift, produced by the Stokes drift (although that latter aspect would not add much to the realism on the time scale of a few seconds).

    • @JumpTrajectory
      @JumpTrajectory  Před 2 lety

      Yeah, the foam definitely should be persitent. There are difficulties in meshing it with the cascades. There are two ways to do it, basically, and both are not perfect. Still working on it, actually. It is relatively easy to make it move with the wave cycles, though.

  • @adamstybrzynski3216
    @adamstybrzynski3216 Před 3 lety +1

    Sir! Thank You for Your work! That's very valuable material and it is a matter of time for Your channel to go viral!
    I would be awesome if You could cover these topics in more details

    • @MaksMikhnevych
      @MaksMikhnevych Před 2 lety

      It is not a matter of time for this channel to go viral. If only you could help this sharing the video in your social channels - that would make an impact, not just random noise.

  • @i_g6676
    @i_g6676 Před 2 lety

    Awesome work, dude! How long did it this project take?

  • @GunnarLoeb
    @GunnarLoeb Před 2 lety

    Great work! Thanks!

  • @ignarmezh
    @ignarmezh Před 3 lety +4

    Hello!
    What parameters can be used to obtain a wave with large peaks as, for example, for Gerstner waves? Or does this method not provide for such an approach?
    Thanks! Amazing work!

  • @TheGreatTimSheridan
    @TheGreatTimSheridan Před 9 měsíci

    It's an amazing effort, I noticed there's also foam around the edge of the rowboat. It seems like there's a little too much uniformity and too much foam. It might look a little boring to remove some of that garnish, but it should look more realistic with less foam or maybe the foam triggers only a little more at the extremes

  • @liluo7513
    @liluo7513 Před 3 lety

    pretty nice video ! thanks a lot !

  • @christopherking6129
    @christopherking6129 Před 2 lety +2

    Neat! I'm surprised inverse FFT isn't used in procedural generation more often.

  • @evanburrows
    @evanburrows Před 3 lety

    Great explanation!

  • @SecretNenteus
    @SecretNenteus Před 2 lety +1

    Fantastic video as always. Do you have more in the works?

  • @CB-hn6pr
    @CB-hn6pr Před 2 lety

    Spectacular !

  • @gamurarandrei2657
    @gamurarandrei2657 Před 3 lety +2

    amazing. Please do more videos like this

  • @jeancolapierrearmande3326

    You're a genius.............thank you!

  • @CrushDepth
    @CrushDepth Před 3 lety

    Following this closely! Currently using Crest HDRP

  • @MaartenVaandrager
    @MaartenVaandrager Před 2 lety +1

    really impressive work! and thanks for sharing. will you be maintaining this as a unity asset for the coming years?

    • @JumpTrajectory
      @JumpTrajectory  Před 2 lety +1

      The code linked in the video is not meant for the real production. It has significant performance problems. I am working on an improved version which I mean to maintain in the future. But I already blew several deadlines on it due to scope creap, so no promices on the release date.

    • @MaartenVaandrager
      @MaartenVaandrager Před 2 lety +1

      ​@@JumpTrajectory thanks for the info. We use oceans a lot for creating HIL test / training simulators for the offshore industry. Yours looks really good and I love your mention of Jonswap in the video. I couldn't directly find any variables related to jonswap spectrum in the editor, that would be really ideal for us as this is often the basis for offshore scenarios. We use really high end pc's so computational efficiency is not the highest priority. anyway, subscribed to your channel :)

  • @Arycama
    @Arycama Před rokem

    Thanks for the video! I'd already implemented my own FFT ocean based on Tessendorf's paper and the phillips spectrum, but didn't quite understand some of the math. This video clears up a lot of it!
    Do you have sources for some of the other equations in your github repo, such as the direction spectrum function, normalization factor, and amplitude calculation for the jonswap spectrum? These were the parts I couldn't find sensible numbers for until I found your repo.

    • @JumpTrajectory
      @JumpTrajectory  Před rokem

      Check out references number 2 and 5 for the info on various spectrums.
      github.com/gasgiant/FFT-Ocean/blob/main/references.md
      The cryptic numbers in the normalization factor function are just coefficients in a polynomial approximation of an actual integral, that I just made in python.
      Also, in my personal experience - you kind of have to fudge the realisic numbers to make a nice looking water. In particular, I find that JONSWAP and P-M both have way too much high frequency waves.

    • @JumpTrajectory
      @JumpTrajectory  Před rokem

      Also, there is a separate .hlsl for that in the newer version github.com/gasgiant/Ocean-URP/blob/main/Assets/OceanSystem/Shaders/Resources/ComputeShaders/Oceanography.hlsl

  • @joshsvoss
    @joshsvoss Před 3 lety

    Really great content.

  • @KingofUshankas
    @KingofUshankas Před 7 měsíci

    AMAZING!!

  • @b33blebrox
    @b33blebrox Před 6 měsíci

    Amazing! Can imagine what enormous computations are required to add there some solitons to simulate waves with negative slope...

  • @Martin-se3ij
    @Martin-se3ij Před 2 lety

    mind boggling.

  • @lemagicbaguette1917
    @lemagicbaguette1917 Před 9 měsíci

    Nifty.

  • @cptray-steam
    @cptray-steam Před rokem

    Mind = blown, I'm probably gonna have to watch this like 30 times before I fully understand how it works.

  • @longpinkytoes
    @longpinkytoes Před rokem

    i would like to see a video about combining two waves from different directions :)

  • @saliherenyuzbasoglu5819
    @saliherenyuzbasoglu5819 Před 8 měsíci

    I hope one day I will be good enough computer scientist that I can understand the concepts in this video

  • @catalingabrielpopa2696

    Amazing video!

  • @DestroierGames
    @DestroierGames Před 9 měsíci

    How do I change the Y position of the water, I would be interested in being able to change it because my terrain is at a different height than the water is when starting the play mode and I can't change it...

  • @user-tt9cb4mh7v
    @user-tt9cb4mh7v Před 2 lety +2

    It is nice to hear your slav accent

  • @sitrakaforler8696
    @sitrakaforler8696 Před 2 lety

    It's incredible !!!!

  • @oliverf.4235
    @oliverf.4235 Před 2 lety

    Great video.

  • @eryberto87
    @eryberto87 Před rokem

    astonishing

  • @MohamedHassan-rh9iu
    @MohamedHassan-rh9iu Před 2 lety +2

    This is an excellent video! I'm a little confused by what the texture above h0k (9:35) is representing, are the values for kx, kz, and omega in the r, g, and b channels respectively? I noticed while reading through your code that WaveData stores vec4, so im a little confused about what data is being represented in the texture. I would appreciate any clarification and thanks again for this amazing video!!

    • @JumpTrajectory
      @JumpTrajectory  Před 2 lety +1

      I store kx as r, kz as g, omega as a and 1 / length of k as b. I stored one over length just for convinience as I had a spare texture channel.

  • @zhehaoli1999
    @zhehaoli1999 Před 9 měsíci

    really nice!

  • @austineadah2843
    @austineadah2843 Před 2 lety +3

    This I nice.can it be implemented and visualized in MATLAB?secondly I was wondering if there could be another video on fluid structure interactions ?

  • @chadx8269
    @chadx8269 Před 2 lety

    Outstanding.

  • @alfiewhitson7726
    @alfiewhitson7726 Před 2 lety

    interesting stuff. Perhaps one alternative way to initially address the tiling issue would be to look at the tiling as a triangular tile of polygons wherein you take a random chunk of said triangle as a sample from the first "tile", re-randomise where the points are going to be drawn in 2d space and then take the edge most points and have it so they are what correlates the next tile to the one before it. So basically don't look at the grid as a grid but rather think of it as something that initially exists as a triangle of triangles but can potentially be manipulated to be an irregular triangle of triangles... think pyramid recursion wherein each pyramid of pyramids is manipulated via Perlin noise but then the gaussian random number generator you're already using is then manipulating in 3d space in the same manner in which you would manipulate Bezier curves where those points will actually be.
    Also in terms of the way in which you're generating the heightmap itself, have you considered, for a final phase in generating the actual heightmap, routing the 2 output textures through some sort of optical flow filter ? The reason I say this is because using this in order to influence the heightmap texture, could in essence apply a layer of recursion to the clumping affect going on within the heightmap texture itself. As far as actually doing the latter would be concerned, I suppose there'd be ways in which you could use the python API for MATLAB to take the actual heightmap texture itself, do optical flow shit in there and then replace the texture buffer that's storing the initial heightmap with the version of the heightmap with optical flow

    • @JumpTrajectory
      @JumpTrajectory  Před 2 lety

      I don't think I really follow what you are saying about tiling, but there is another reason to use the cascades, that I could have explained better in the video. The cascades greatly improve the dynamic range of the FFT. To represent a plausible water surface you need wavelengths from ~1cm up to the hundreds of meters in choppy sea. To cover this range of wavelengths you have to use multiple FFT domains, otherwise the required resolution becomes insane.

  • @shokhzodalimardanov5659
    @shokhzodalimardanov5659 Před 2 lety +2

    Great work! I am researching FFT and shader languages to develop the same ocean simulation myself. Do you think the shader graph of unity can make this simulation as well? It is a lot of math and I wonder if it is worth making so much effort as the shader graph seems easier. What do you think?

    • @JumpTrajectory
      @JumpTrajectory  Před 2 lety +3

      There is a lot of math involved in the simulation, so implementing it inside a node system would be extremely cumbersome. The shader that uses the resulting displacement/normal maps to render the ocean, on the other hand, is reasonable to implement in something like Shader Graph.

  • @minusinfinity6974
    @minusinfinity6974 Před 2 lety

    Awesome video. How do you get the white caps on the waves?I didn't see an explanation for how that was modelled.

  • @prathameshsundaram7509

    Great video!