0
\$\begingroup\$

I want to render an ocean where players can change waves’ amplitude in real-time. Initially, I would render rolling waves (see picture). As the amplitude increases, I need to transition the rolling waves into breaking waves (see picture). For now, I am not going to show the shoreline onscreen so I don’t need to render breaking waves interacting with the shoreline; I only need breaking waves on the open ocean.

I’ve tried three different approaches so far and I’ve only had success with rolling waves using approach 1. Breaking waves have been impossible so far with all three approaches.

Approach 1: Mesh deformation

  • I can create smooth rolling waves using the Sine and Gerstner equations.
  • Since I can’t use these equations for breaking waves, I tried to implement them by using this free plugin whose output is similar to this paid mesh deformation plugin. But there are 2 problems with this plugin approach:

Problem 1: There is no smooth transition between rolling waves generated by approach 1a and the breaking waves generated by the Deform plugin

Problem 2: The output of the plugin does not look similar to real breaking ocean waves in three different ways:

i. No smooth blending with the ocean surface

ii. A large depression is created below the crest

iii. The entire wave is the same height (rather than with more realistic variations)

  • I considered using vertex shaders but this approach seems similar to mesh deformation.

Approach 2: Fluid dynamics + metaballs

  1. To render an ocean I will need thousands of particles which will be too expensive in terms of performance (especially for mobile devices).

Approach 3: Using mesh files

  1. I can create breaking waves using some 3D software like in this post but then I can’t modify the ocean in real-time. It will be more like a pre-rendered simulation.

To summarize, I am looking for an approach where I can vary ocean waves’ amplitude for a smooth transition between rolling waves and breaking waves.

\$\endgroup\$
  • \$\begingroup\$ I tried searching this online, and can find a lot of different ways to do this both in 2D and 3D. Did you try any of those? Did you get stuck on any specific step? \$\endgroup\$ – TomTsagk Oct 16 at 14:54
  • \$\begingroup\$ Thank you for the reply and sorry for the trouble with the post. I've now changed my original post to be more clear about my goal, what approached I've tried, and where I'm stuck. Please let me know if you have more questions \$\endgroup\$ – Nimesh Chandramaniya Oct 17 at 10:05
1
\$\begingroup\$

I understand the local need (moving from rolling waves to breaking waves), but as I can't figure out the larger need (how the game will evolve around this) my answer might just be out of place as highly theoretical. But let's try it.

Have you considered using approach3 but only on small patches of your mesh? You have that mesh of yours with small waves on it... then you know where your wave center is, and the highest point of it. You could, on that very specific place where you want to have a breaking wave, display a mesh you'd have created in a 3D software. The trick here would be to move the vertices / or create new ones for the breaking wave base to fill the gap between wave it's supposed to replace and the other ones. Once your 3D mesh is in place you can play an animation to let it finish its movement and even play with its scale. Add to that some nice particles and it should do the trick.

TL;DR: remove the small rolling wave you want to break from the mesh, fill the empty gap using a 3D mesh modeled in a 3D software, fill the gap et voila.

\$\endgroup\$
  • \$\begingroup\$ Thank you for your reply. I understood your suggestion partially that I should mesh in real-time from the rolling wave mesh to the breaking wave mesh. But I think that transition will look abrupt and odd. Also, can you please explain this sentence "The trick here would be to move the vertices / or create new ones for the breaking wave base to fill the gap between wave it's supposed to replace and the other ones."? \$\endgroup\$ – Nimesh Chandramaniya Oct 22 at 12:39
  • \$\begingroup\$ I'm sorry if I wasn't clear. I just meant that removing a part of your mesh (where the rolling wave is removed to put a precomputed crashing wave instead) will probably generate "gaps" and you'll have to fill that gap to connect your crashing wave to the rest of the mesh. \$\endgroup\$ – lvictorino Oct 22 at 12:53
-1
\$\begingroup\$

You can use a shader to achieve the effect. Unity's new "Lightweight Rendering Pipeline(good for Mobile) supports "Shader Graph"; so you can use "shader graph" to create good looking wave, you can use change values of the material to control the wave and other stuff.

This tutorial can be a good start!!

https://www.youtube.com/watch?v=FbTAbOnhRcI

\$\endgroup\$
  • \$\begingroup\$ Thank you for your reply. That tutorial is good for creating rolling waves. But you can't create breaking waves (as shown in my reference my image) with shaders. \$\endgroup\$ – Nimesh Chandramaniya Oct 19 at 10:55
  • 1
    \$\begingroup\$ @NimeshChandramaniya I'd be careful saying you "can't" do anything with shaders. Modern shaders are Turing-complete. Check out some of the stuff people do on shadertoy.com. \$\endgroup\$ – Omegastick Oct 21 at 4:30
  • \$\begingroup\$ @Omegastick Sorry I went too hard on shaders. I wanted to say that the logic to create breaking waves won't depend on whether the waves are created using shaders or some C# script. \$\endgroup\$ – Nimesh Chandramaniya Oct 21 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.