Archive 17/01/2023.

Fast FFT Ocean :ocean:

Lumak

I came across this site - http://www.keithlantz.net/2011/11/ocean-simulation-part-two-using-the-fast-fourier-transform/, and wanted to observe the frame rate in Urho. His code is written very well. I literally just copied and pasted his code and changed a couple of vector classes to Urho’s and had it running in few minutes.

Runs at around 40 fps running in the main thread. Shader stuff next.

rasteron

Looks good! :slight_smile:

Lumak

Yes, Mr. Lantz did an awesome job optimizing his FFT. It’s the best that I found showcasing Ocean Simulation.

Lumak

frame rate running in urho 1.5, wave process running in a separate thread, using water.xml material

Victor

I’m really excited about this! Nice work!

krstefan42

Wow, looks great! That’s running CPU-side? Pretty impressive stuff. I imagine it would benefit from a multi-resolution grid (with higher res closer to the camera). When you are done, could you share the modified source and an example? I’m feeling lazy and would rather not try to get it running myself. :wink:

Lumak

@ krstefan42

Not sure how I missed your post, but sure, I’ll create a repository for this (not anytime soon though).

Lumak

Now that Cadaver made some performance improvements, I should work on this soon™.

Lumak

Repository: https://github.com/Lumak/Urho3D-Ocean-Simulation

I’m still not satisfied with the shading of the ocean and the reason why I was reluctant to create a repository for it. But I decided to create it and perhaps, one of the graphics programmers can tweak it.

Lumak

Added glsl ocean shader in the repo.

Lumak

Added hlsl ocean shader. I think that will be the extent of my graphics/shader enhancement. There are a lot of other really cool ocean shaders out there, but most are too complicated and beyond my skill set to duplicate :slight_smile:

Miegamicis

Looks good, thank you :slight_smile:

larsonmattr

Why do you need to use an FFT for the ocean shading? Is this more complex than a shader that uses sin functions to move up and down vertices?

[Found that there is a blog post describing this further]
Looks like a far more complex simulation of waves and choppiness, so that is probably why it is doing some more complex wave math.

Lumak

[quote=“larsonmattr”]
[Found that there is a blog post describing this further]
Looks like a far more complex simulation of waves and choppiness, so that is probably why it is doing some more complex wave math.[/quote]

That’s correct. FFT is used for wave simulation, not shader.