Getting somewhere with my waves rendering. It's fully driven by wind speed based on actual physical models, and runs mostly in the vertex shader so it's speedy too.

#GodotEngine #Godot #GameDev #IndieDev #IndieGame #ProceduralGeneration

@thomastc Ooooooph that's sick!
@lisyarus Seasick, you mean? Honestly I'm feeling a bit queasy after looking at this stuff for hours...
@thomastc that's so pretty! How does it work? ​
@dfxluna I'll write a blog post later, but the toot version is: a sum of Gerstner waves, fBm-like, for vertex positions. Out pops also a phase angle, indicating where the crests are; put foam around crests and trailing after them. Foam density is thresholded into a static cellular noise texture using smoothstep. The normal map is a weighted sum of four randomly shifted instances of a simplex noise texture, fading in and out to give the fine details.

@thomastc Nice! The pixel art feels really really cool there.

I think we're doing waves the same way. Eager to hear how you're dealing with changing wind directions. (I’m just sending waves in every direction and dampening ones not aligned with the wind. :D)

@jonikorpi Similar! Each wave has a lifespan, fading in at the start and out at the end. When it respawns, it uses the new wind speed and direction.
@thomastc Ohh, smart!
@jonikorpi Not my idea. Probably got it from a GPU Gems chapter?
Around The World, Part 30: Making better waves

I previously blogged about how I’m modelling and rendering water waves in the game, but that was in the previous incarnation on a sphere. I’ve finally ported that over to the current version, and made some considerable improvements along the way. People told me it looks good, and I tend to agree. Let’s dive in!

@jonikorpi I used your idea of having all waves be persistent and only allowing the ones that align with the wind. It turned out better than my other approach. Thanks!

@thomastc Hell yeah, looks great!

You have WAY more waves than I could ever run, but I’m guessing you're simply skipping over the ones that are inactive, so performance stays quite good in the end?

@jonikorpi Around 200 total I think. Only active ones are passed to the shader, which is limited to 64. I think the ray march for reflections is limited to 32 steps, but that one is doing texture lookups rather than simple arithmetic, so it's way more expensive than a few more waves.

@thomastc Ah so they still live on the CPU… hmm.

I have 21 always-active ones on the GPU. About half of them are always so dampened they barely have any effect.

Now wondering if it would be feasible to stay on the GPU, increase to 34 or 55, and try to save performance by early-exiting the ones that are very inactive.

Your way would definitely be more responsible though. :D

@jonikorpi What is so performance intensive about them? It's just a handful of additions and multiplications for each... peanuts for a GPU even when done per pixel. Even sin and cos take only a single cycle nowadays.
@thomastc Maybe it’s the ancient API I’m on (WebGL 2) or maybe I should be precomputing more, but they’re definitely beating me up! I’m also targeting non-gaming GPUs, which is probably not helping.
@thomastc This looks great!!
@thomastc @dfxluna Thank you for the explanation. So, you mean that waves are not just a visual feature but a specific object that you spawn and track?
@dfxluna @ThibaultJ Essentially yes. They have an origin point, direction vector, amplitude, wavelength and period. In Godot I represent them as Node3D but they might as well have been structs – they have no *direct* visual representation.
@thomastc neato! Thanks a bunch​
Around The World, Part 30: Making better waves

I previously blogged about how I’m modelling and rendering water waves in the game, but that was in the previous incarnation on a sphere. I’ve finally ported that over to the current version, and made some considerable improvements along the way. People told me it looks good, and I tend to agree. Let’s dive in!

@thomastc It is already hard to do the waves normally, but in pixel art... they look really awesome! -D.
@thomastc DANG that looks good.
@thomastc that looks extremely good, nice job!
@thomastc beautiful! 😍
@thomastc that's so amazing. But how ?
@ThibaultJ There's a brief explanation elsewhere in this thread.
Around The World, Part 30: Making better waves

I previously blogged about how I’m modelling and rendering water waves in the game, but that was in the previous incarnation on a sphere. I’ve finally ported that over to the current version, and made some considerable improvements along the way. People told me it looks good, and I tend to agree. Let’s dive in!