Hi all,
I’m working on a game that includes an ocean. My first attempt was to implement it using Gerstner waves, but I wasn’t convinced by the result, and I happened to come across this project on GitHub.
I adapted the project for Panda3D and improved it using compute shaders. I’ve put together a small sandbox app to play around with the ocean, and I hope you like it. I am happy with the results ![]()
What This Project Is
p3d_ocean is a real-time GPU ocean simulation + renderer built on Panda3D.
It implements a Tessendorf-style spectral ocean: waves are simulated in the frequency domain, then transformed back into spatial displacement/normal maps and finally rendered on a tessellated grid mesh.
How It Works (Pipeline)
-
Initial spectrum (startup): a compute shader generates the base wave spectrum from parameters like ocean patch size and wind vector.
-
Time evolution (per frame): another compute stage advances random phases and builds the time-varying complex spectrum (including “choppiness” for sharper crests).
-
2D inverse FFT (per frame): the project runs a full IFFT on the GPU using horizontal + vertical butterfly passes, ping-ponging between textures across log2(N) stages.
-
Maps generation (per frame): the IFFT output is unpacked into a displacement (height) map, then a slope/normal map is derived for lighting.
-
Rendering: a large subdivided plane is displaced in the vertex shader, shaded in the fragment shader with basic physically-inspired terms (specular/roughness, subsurface scattering tint, depth-based absorption), and optional refraction using an offscreen scene color+depth buffer. A tiled detail normal map can be blended in and distance-faded.
Any ideas, comments, or criticism are more than welcome. The shading still needs a bit more work, but I’m pretty happy with the result.
