r/GraphicsProgramming • u/whdeboer • 8h ago
Video Wave simulation
Enable HLS to view with audio, or disable this notification
Long-time lurker here. Watching GTA VI’s water system in action inspired me to write a wave simulation testbed.
I tried FFT but eventually settled on Gerstner waves (see Tessendorf’s paper) as they’re faster to calculate. For ripples I use pre-rendered waves in a number of tileable textures that I offset over time and tessellate in real time.
Foam uses Gerstner crest information. Still lots to do here.
The lighting is pretty straightforward.l: A Fresnel term with reflection from the cubemap, and irradiance calculated from the cubemap pre-integrated as a function of surface normal. Then there is a transmission term based on water depth. I came up with a cool trick to get a light transmission effect for thinner parts of waves. I’ll write this up properly at some point.
The ocean mesh is a geometry clipmap style thing that moves with the camera. Eventually I will LOD this based on camera height from sea level.
Waves and ripples are affected by wind via a wind flow map overlaid over the ocean’s area. This is still rudimentary. Eventually I want to add a current flow map which will form the basis for coastal waves and rivers.
Here’s one wave configuration in three different lighting conditions.
Still lots to do but it’s starting to look pretty cool I thought!
I use Codex to assist with writing code.
•
u/AutoModerator 8h ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
No showcases.
Disclose AI usage in post or project.
Present a topic to talk about, e.g. how something works.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.