🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Creating 3D water on Unity for iOS/Android

Started by
4 comments, last by Octane_Test 4 years, 8 months ago

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

a.     I can create smooth rolling waves using the Sine and Gerstner equations.

b.     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:

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

·      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)

c.      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. Please let me know if you have more questions.

Advertisement

Things you start out with:

  1. define, what perspective the player can have. If the player only ever sees the sea from top down, you can keep the "3D" much more simple. A flat angle (being close to the ground) requires you to have actual 3D models, but the player could only see the first few waves.
  2. define the distance from the water. Again, the further the player (/the camera) is away from the water, the simpler this can be done. If he's far enough, there would only be little difference between 3D and just textures. Being a bit closer, you could have simple 3D geometry and add the details using textures.
  3. define the art style. The more it leans to realistic, the more detailed everything has to be
  4. Will these waves be "animated", or will you just render a single point in time?

Keep in mind: you're trying to do this for mobile. If you're really only interested in drawing waves and no other gameplay content, then it might not be as much of a problem, but if you want/have to stick to a certain hardware limitation, you should think about the things listed above, since all of them influence the performance.

Thank you for your reply. Below is further information matching your points.

  1. The camera perspective will be similar to this image.
  2. The required view of the breaking wave is similar to this image.
  3. I am trying to implement the toony art style as shown here (see video).
  4. Yes, the waves will continuously animate.

There will be other gameplay elements such as surfers and hence I am looking for a mobile-friendly solution.

I just found Art That Moves: Creating Animated Materials with Shader Graph, which might be interesting, but it still lacks the breaking waves you want to have in your game.

It might help to think of waves as particles in a circular motion. Waves would break if the amplitude grows without enough water in front of the wave (closer to the beach).

Thank you for your reply. I have tried the approach mentioned in the "particle in a circular motion" approach but the output doesn't look like the target output.

This topic is closed to new replies.

Advertisement