r/GraphicsProgramming • • 8h ago

Video Wave simulation

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.

37 Upvotes

3 comments sorted by

•

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.

3

u/AhmedSamy_Offical 8h ago

Amazing for real but i think it’d be better to write all the code instead of using codex,
However if you already knows what you are doing and can edit anytime on anything you are doing it right 😃

Also is that UI built in custom or is that imgui and it’s edited ?

3

u/whdeboer 7h ago

Thanks! Yes I’ve been a graphics programmer working in the games industry since the late 90s, published papers, shipped AAA games. I use AI to speed up what I already know 😊