Announcement

Collapse
No announcement yet.

WIP - Real Time Water Waves and Physical Water Surfaces

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    WIP - Real Time Water Waves and Physical Water Surfaces

    I've been working on creating a realistically accurate fluid surface that involves not only Water-To-Object coupling (buoyancy and other forces) but also Object-To-Water coupling (objects creating dynamic waves on water surface on interaction). Being a physics engineer myself, the nature of waves is very understandable for me. It took a lot of research and a bit of theory-crafting (and much, MUCH more math ) but I think this is actually possible to do now! Anyway, I got very excited for achieving some kind of success with this so I couldn't stop myself from sharing it and seeing what you think!

    Before I get into more detail, here's what I've got so far: (excuse the horrible looking water, it's just a simple water shader for testing purposes)



    Not only that, but these waves also have reflection capabilities - they reflect off of the walls! To illustrate :



    This is a physically accurate water model as well! Creating a water surface that has buoyancy (floating objects) is relatively easy with the use of Gerstner wave equations (a lot easier if you've worked on quantum wave equations for a few years ). I believe Handkor was the first to implement this and he even has an amazing tutorial for it. This however gives us only roughly ~1/3 times the accuracy as compared to what is actually going on a fluid surface, since there are 3 main different forces (for simulation purposes at least) acting on an object when it is interacting with a fluid surface and we are accounting for only 1 of those. These are; buoyancy, drag and lift forces. This is what creates the motion that makes the tip of a speed boat go up and down in water (it's mainly the lift force).

    Anyway, this water model actually has all those 3 forces, meaning that it is physically accurate. I got too excited when my idea of creating realtime waves worked that I couldn't get down to recording a video for the physical aspect of this model, I'll have one asap

    With this model, the ambient waves on an ocean surface interact with the waves created by the object and vice versa thus creating a fully realistic fluid surface look and feel. I did not yet take the time to adjust the coefficients in the equations yet so that's why the waves you see in the videos are somewhat unrealistic right now.

    The generated waves apply only a vertical deviation on the surface for now, I have not yet figured out the method to effectively add in the longitudinal deviation. That'll really enhance the visual realism of the waves by causing them to be somewhat steep.

    The waves are generated realistically and according to the surface of the used mesh. What this means is that the waves change according to the relative speed(to the surface), shape, area etc. of the faces of the mesh.

    Mathematically, the waves are generated with about 10% of error and the physical accuracy of the water (both when it is just floating and when it is moving on the surface) has about 7% error to it, provided that the coefficients in the equations are within acceptable error rates themselves as compared to the faces of the used mesh. The physical accuracy can be further increased by accounting for more of the forces aside from the 3 we are using, but unless you want to use this for academic purposes I don't think that is necessary. You can decide for yourselves when I record a video of it being propelled in a wavy surface

    This is being done for a game that I'm in charge with developing; however if I can further refine it to have an optimal performance cost then I'll probably take the time to release a very small game/project that basically simulates fluid surfaces and lets you experiment with them with all the physical aspects (kinda like what BeamNG Drive is doing). It may also end up having academical uses.

    This is a very broad work to sum up so feel free to ask any questions and I'll be happy to provide details and answers accordingly! I'm sorry for making this post so disorganized but I simply got too excited! Effective and physical fluid surfaces have been the open wound for games () since actual fluid simulation methods are impossible to use for real-time purposes due to their exceedingly high performance costs. How cool would it be if UE4 would be a platform for this to be possible in!!

    If this is not just me rambling and this is actually an interesting and exciting topic for others as well, I'll take the time to refine this post into a proper form from where the development of this model can be easily tracked!

    This is all based on the Wave Particle theory by Cem Yuksel : http://www.cemyuksel.com/research/wa...eparticles.pdf - that's where all the math is coming from for my implementation!
    Last edited by k.alpha; 05-18-2016, 02:48 PM.

    #2
    I mean, this looks awesome and I'd love to use this in my project, but I have to wince as I ask - what's the performance cost of this? I'm speaking on behalf of the ~50 sailing vessels that will be player-controlled and fighting each other in the water.

    Comment


      #3
      Wow! You have all reason to be excited. This is great!
      A physicist by trade myself who has spent to many hours with Schroedingers equation and Quantum what not, I am glad to see that those things are actually useful for something (not working in that field anymore).
      I would be really interested to see some math background. Not every detail, but just what you used and how you did the wave coupling. Also how you solve it iteratively.

      Comment


        #4
        Right now the cost is unacceptable to sum up in terms of fps, we're talking 10-15 drop for accurate waves - accurate means each wavefront is killed after it travels about 500 units, a single wavefront consists of sub-waves that are placed 75 units apart, the check for generating the waves is done each 0.1 seconds and the resulting height field texture is 128*128 (there are some other parameters as well). Half the cost is coming from the waves themselves and the other half is coming from the way I do the check for generating the waves.

        Good news is, I'm currently working on a filtering method (kinda like a convolution filter in principle) which -if I'm successful with it- will eliminate the cost coming from the generating-the-waves part of things. That will be a good starting point for judging the performance; I aim to have it close to zero cost for low-quality waves, 1-2fps for medium quality waves and a max of 5 fps for high quality waves. It would still not be suitable for a 50 vessel fight scene if you want good looking waves, if you're just looking for that "feel" of the water surface to enhance immersion I think it would work with low quality waves and give you that feel.

        To sum up, give me about one more week before questioning the performance side of things I'll give a much more accurate report of the performance cost then.

        Oh and this is all the object-to-water part of things. The water-to-object (i.e. the physical simulation part of things) is easier and I can probably optimize that to have no cost at all in the future.

        Comment


          #5
          can you go with milliseconds? Maybe just use the 'stat unit' command and show the game/draw times and on what hardware. Talking in fps differences makes it difficult to judge performance (100fps - 90fps is lower cost than 20fps -10fps....)

          Comment


            #6
            Originally posted by BlueBudgie View Post
            Wow! You have all reason to be excited. This is great!
            A physicist by trade myself who has spent to many hours with Schroedingers equation and Quantum what not, I am glad to see that those things are actually useful for something (not working in that field anymore).
            I would be really interested to see some math background. Not every detail, but just what you used and how you did the wave coupling. Also how you solve it iteratively.
            I'm really glad you think so! The quantum what-not has been very helpful for doing this, much to my surprise too

            I can not take credit for the theory-background of this! All the theory crafting comes from a theory called Wave Particles (http://www.cemyuksel.com/research/wa...eparticles.pdf) - my model here is an implementation of that theory. I had to tweak and work on it a lot but still it is based off on that. Math-wise, the idea is quite simple: you define particles and assign them local deviation functions. Since the superposition of all these particles will correspond to a wavefront, each individual local deviation function is not required to satisfy the wave equation for as long as the sum of all the deviations satisfy your starting wave equation as a collection. Take a look at the link and I'll clarify if you have any further questions

            Now that I think, I should probably add where the theory comes from to the main post. I'll do that right away!

            Comment


              #7
              Originally posted by BlueBudgie View Post
              can you go with milliseconds? Maybe just use the 'stat unit' command and show the game/draw times and on what hardware. Talking in fps differences makes it difficult to judge performance (100fps - 90fps is lower cost than 20fps -10fps....)
              You're correct; but for as long as the fps difference is unacceptable to begin with I did not feel the need to show the stat unit times I usually do not start actually analysing the cost in detail before I hit the acceptable fps difference mark when working on singular tool and not a whole project. As soon as I finalize my current work on the filter method I mentioned and I'm sure that the core structures of the model won't need anymore changes, I'll share the numbers in detail!

              Comment


                #8
                I found this video showcasing the technique. I have to say, it is really impressive. Starting from 2:10min is impressive. It runs real-time on 10 years old hardware. From what I gathered so far, reducing the number of wave particles obviously lowers cost. The thing is, with such an pronounced physical effect, it would not have to be that accurate if mixed with fancy decals or something similar creating wake foam and splashes and effects to keep the eye busy.



                No need to hurry with the numbers. Looking really forward to see some more results from you! (and the actual game)
                Last edited by BlueBudgie; 05-18-2016, 03:38 PM.

                Comment


                  #9
                  That video is precisely what I'm hoping to achieve! I've watched it many, many times. I'm happy to hear you find that video impressive as I do, will keep ya updated! How great it would be if this ends up looking like that video

                  Comment


                    #10
                    Only one thing to say in a situation like this **** YEAH please excuse the excitement.

                    Comment


                      #11
                      Originally posted by k.alpha View Post
                      That video is precisely what I'm hoping to achieve! I've watched it many, many times. I'm happy to hear you find that video impressive as I do, will keep ya updated! How great it would be if this ends up looking like that video
                      'Would'? There is no 'would' in this equation
                      I researched the topic a bit more and found the creator's website.
                      http://www.cemyuksel.com/
                      I am sure if you just contact him and tell him that you integrate his stuff in UE4, he would be happy to advise you.
                      (He looks a bit like one those dangerous wrestling stars from the 80's, but other than that seems to be harmless)

                      Comment

                      Working...
                      X