Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Assets Water system based on baked fluid simulation

Discussion in 'Works In Progress' started by NHydro, Nov 13, 2017.

  1. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Hello, recently I've been working on a water system for rendering fluid simulation in Unity. Currently, work is under way to simulate and render the ocean near the coastline. The fluid simulation itself is performed using the particle-in-cell method, then this module uses the saved data (fluid surface and particles) for rendering.

    The video below shows a simple example of simulating the surf zone (5 second loop). For better quality watch in 4k.





    There are obvious flaws in the video (development is in progress), but it gives the general idea.

    It is planned that this module will require about 512 MB of video memory. For each type of shoreline, 50-200 MB of disk space is required. If there are 20 different types of shoreline in a game, it will require 1-4 GB of disk space depending on the complexity of the flow.

    Now, work is underway to create a library of different types of shoreline, combining which (manually or procedurally) the game level is created. By type of shore is meant a geometry that affects the behavior of the fluid near the shoreline. Color, texture, the presence of additional objects, whose difference in geometry does not affect the flow, can be arbitrary.

    The shoreline will be constructed in two stages:
    1. Drawing a spline;
    2. Filling the shoreline with different types of shore along the spline (for example sandy beach, rock, pier, shipwreck, seawall, …).
     
    Last edited: Dec 29, 2017
  2. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,158
    It looks fantastic ...do you plan to release as asset ? when ? need beta tester ?
     
    jbb1979 likes this.
  3. norby

    norby

    Joined:
    Jul 10, 2006
    Posts:
    268
    Wow wow wow, this looks incredible, the best shoreline i have ever seen :)
     
    jbb1979 and Kridian like this.
  4. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    404
    Can`t believe what i see here, fantastic.
     
    jbb1979 likes this.
  5. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    240
    That looks awesome, great work!
     
    jbb1979 likes this.
  6. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Yes, we have such plans. Now the work is far from complete. Many things need to be figured out.

    Now I'm working on data compression, the small example of the simulation shown above now requires 700 MB of video memory for textures. I'm sure that we’ll get a compression ratio of 30-40%, totaling about 250 MB. This is just for the shoreline, also games may require: boat wakes, splashes, streams, etc.
    In the first message I've paraphrased the questions I'm concerned about. I would be grateful if you could answer them.
     
    jbb1979 and Bartolomeus755 like this.
  7. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    240
    I work on a maritime simulation. So I need to have all these feature. Very important is a boundless ocean and also boat wakes splashes and of course underwater view. Performance is of secondary importance because I don't want to support mobile platforms. Nevertheless I need enough performance to create realistic sceneries.

    I really want to see an finished water asset of your work. I like the look and movement of the water. And the shoreline looks outstanding.

    Marko
     
    jbb1979 and JamesArndt like this.
  8. norby

    norby

    Joined:
    Jul 10, 2006
    Posts:
    268
    Hi Nhydro
    I am not a coder but could you use procedural textures for your foam ?

    Norby
     
    jbb1979 likes this.
  9. MarcClintDion

    MarcClintDion

    Joined:
    Aug 27, 2013
    Posts:
    4
    This years top gaming cards are averaging 8GB of VRAM and mid-range gaming laptops from 2015 like the one I have are in the neighborhood of 2-3GB of VRAM.

    Now if the average game takes roughly 4 years for a team to build then it's entirely possible that the average gaming machine will have a minimum of 4GB's of VRAM by the time you are finished if that's not already the case now.

    No matter what happens with that, what you are doing is entirely practical because it's amazing and everyone wants to see a game that looks that good.
    Even if all you make is a tech-demo that most machines can't run, you'll have so many job and partnership offers that what you are doing will eventually come to something big. If you end up meeting someone who knows how to optimize your work then you have no problem at all.

    If it's awesome, people will buy better machines just to play it. I haven't heard anyone say "killer-app" in a long time. Bring it back!
     
    jbb1979 and ftejada like this.
  10. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    With amplify texture it should not be a problem.
     
    jbb1979 likes this.
  11. PhilippG

    PhilippG

    Joined:
    Jan 7, 2014
    Posts:
    253
    Really impressive! Would be incredible in VR!
     
    jbb1979 likes this.
  12. csgood111

    csgood111

    Joined:
    Oct 4, 2017
    Posts:
    1
    Wow. This is the best ocean asset that i have ever seen. I would love to feature it in my game or in upcoming projects. Are there any details about this being made public being available? I'd love to test it. The video shown looked amazing in a experimental state. Need a tester?
     
    jbb1979 likes this.
  13. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Thank you very much for your comments, I'll keep you informed every few weeks on progress.
    All information will be posted here.
     
  14. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,628
    Looks really really nice. :) A ton of particles!
     
    jbb1979 and JamesArndt like this.
  15. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,584
    I think some projects would have no problem with 256-512MB. A gig isn't practical for games but Unity serves many markets that don't care about limitations - they will throw more hardware at it (sim, military, arch vis, film)

    This is impractical for the scale given, for most games but again see the above comment, Unity doesn't just serve game markets :)

    Ideally a solution like this for console games, would not cost more than 256MB of video memory and have a fixed storage size regardless of how much it's used, so some form of reuse would be interesting.

    This is only my opinion in relation to things similar to my current project.
     
    jbb1979 likes this.
  16. norby

    norby

    Joined:
    Jul 10, 2006
    Posts:
    268
    Hi NHydro

    Any new ideas for implementing your water system ?
     
    jbb1979 likes this.
  17. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Hello,
    The next question is how to design a game level with a shoreline. As far as I understand, the standard method assumes that firstly the sculpting of the terrain is made and then the ocean plane is placed. In this case, this method is hardly possible, the simulation will take a lot of time to calculate and a lot of disk space for storage.
    To solve this, it is proposed to create a library of different types of shoreline, combining which (manually or procedurally) a level is created. By type of shore is meant a geometry that affects the behavior of the fluid near the shoreline. Color, texture, the presence of additional objects, whose difference in geometry does not affect the flow, can be arbitrary.

    The shoreline will be constructed in two stages:
    1. Drawing a spline;
    2. Filling the shoreline with different types of shore along the spline.

    Below is an example of the layout of a coastline (about 500 m) using 6 types of coast.
    1. Sand (5)
    2. Rocky beach (2)
    3. Transition Sand - Rocky beach (1)
    4. Transition Rocky beach - Sand (1)
    5. Pier (1)
    6. Shipwreck (1)

    shoreline.png
    Below, as an example, a video of one of the shoreline segment (bridge pier) is shown.



    Question:
    Would it be convenient to use the above-described scheme for constructing a shoreline in the production of games?
    I would really appreciate your answers.
     
  18. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    475
    will this be a unity package for sale i wonder
     
    jbb1979 and blitzvb like this.
  19. norby

    norby

    Joined:
    Jul 10, 2006
    Posts:
    268
    Wow this looks amazing :)
     
    jbb1979 likes this.
  20. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    685
    Awesome! The best shoreline of ever!!
     
    jbb1979 and Kridian like this.
  21. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    198
    wow. Will this be usable with other fluids like honey or lava as well?
     
    jbb1979 likes this.
  22. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Yes, the possibility to simulate and render fluids with high viscosity is certainly present. In addition to the increased viscosity, for such fluids a more complex mesh should be used (not height map based). Right now work is underway to implement data compression for rendering complex surfaces (for example plunging waves).
     
    jbb1979 likes this.
  23. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    198
    Very cool would really like to see a demo of a high viscosity fluid. :)
     
    jbb1979 likes this.
  24. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    531
    hi @NHydro

    The best I've seen. It is light year from all the other assets.

    As soon as it goes on sale, you already have an insured buyer. I'll see how I put it in the game, but something so impressive must be in mine.
    Games with asset of very high quality, they sell more powerful hardware to be able to play them. In addition the technology advances very fast ... the graphics cards already go by 11Gb of memory

    regards
     
    jbb1979 likes this.
  25. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,068
    Really awesome shoreline. Love it. Now I'll try to answer your questions:

    1) It's not very practical for most hardware to use that amount of video memory only for foam textures. So if you find ways to reduce it, your market will expand tremendously. Otherwise you will be limited to high-end hardware. Also many will try to run it on VR and if the system is running at 60fps only with a shoreline... the game will probably slow too much when adding all the other stuff.

    2) The disk requirement you mention is also way too high. If 200 meters of beach requires 1gb of space... again, high end hardware and you'll be out of many potential markets.


    So my suggestions...
    1) Give a try to sell as it is now. You've get lot of customers that have high end hardware and don't mind all those crazy requirements. You'll also get some $ and real market use requirement metrics that will guide you through the following point...

    2) Begin working on optimization and lowering quality. Tricks to probably discard memory batches at a given distance and replace them with lower quality particles/meshes the farther you are. Lastly, most of game developers would love to have a nice shoreline, but we don't need crazy quality and details. We just need something that looks better that what we have without slowing our game. All current shoreline systems that I know of, looks pretty bad.

    To give you an idea, this level of quality would be way more than enough for most of us:



    and



    I hope I was helpful. Your shoreline rocks and I'd love to give it a spin.
     
    Last edited: Dec 28, 2017
    jbb1979 likes this.
  26. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    531
    Hi @NHydro

    I think here the first thing you should assess is what line you want to get for your asset (Quality / real simulation or performance).

    Once decided that focus your project from there.

    I understand that performance is something very very important and I think you should work to get the best possible performance, but if what you want for your asset is quality / simulation of reality, you can not sacrifice quality and visual realism to get more market, because you will always be tied by the quality you want for your asset ... so I would only be oriented to high-end / very high-end PCs.

    From here my reflecsion of the old post ... The hardware advances extremely fast and the necessary requirements of disk, vram, etc that now seems crazy, in 3 years it can be something normal.

    With this I do not say that I do not try to work at the maximum possible performance, but always from the perspective in which realism is not lost.

    Other options are that the user who uses the tool can choose what kind of visual realism he wants and that each one chooses if he prefers more performance or more realism.

    I do not know if this is a silly idea, but I say it in case it serves you ...

    What if instead of creating an ocean asset like the one you do, you only create a shoreline asset that could be used with any other water asset?

    Maybe this helps focus things differently so you can have similar results in realism for your asset without being brutal in performance.

    Maybe the waves and foam that are generated, as you say are reusable, that you can choose the distance of coastline that would use that wave and foam data.

    As @ creat327 says, that according to the distance to the camera or the player, waves and foam are executed with less quality LOD's style (The highest visual realism only for the first 10-15 meters from the camera or player) and things like that ...
    Although I imagine that all these things you have already valued.

    Techniques so that the only thing that is rendered of your asset is only what enters the frustrum of the camera.

    I speak from ignorance, but to launch ideas and some can help you.

    regards
     
    jbb1979 likes this.
  27. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Below is an attempt to simulate the flow near a sea wall (still looks unnatural).
     
    Last edited: Dec 29, 2017
    jbb1979, Gekigengar, Elecman and 10 others like this.
  28. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,135
    Looks fantastic, keeping an eye out for his one!

    Multiple render settings would be a good options. low / medium / high for texture quality and simulation quality.
    So the game could detect the system capabilities and adapt to that.
     
  29. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,112
    Looking pretty realistic if you ask me.
     
    hopeful and sjm-tech like this.
  30. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    685
    Wow it looks good indeed!!
    Maybe with some interactive wetness on surface (like in the shoreline) should give more realism and looks less as you said "unnatural " (for me is already awesome) ;)
     
  31. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    240
    Looks great, looking forward to this water asset!
     
  32. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,913
    Very interesting results, with curious limitations (at this point). Glad to see someone raising the bar again on water simulation. :)
     
    ftejada likes this.
  33. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    138
    Are you rendering the particles inside Unity - are you using your own particle in cell simulator or third party app?. Also, which ocean system are the demos? Aquas? playway? Tell us more on implementation, cheers..
     
    JamesArndt likes this.
  34. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,395
    That would not really work for most games, and the approach just wouldn't mesh well with most of the terrain creation assets either. So you would have a very limited audience, like a small handful at best.

    Also, realistic is often not what you want in games. A great example of this is Sea of Thieves which is getting all kinds of praise for it's water. And if you look closely you will see the water doesn't really behave like real water does in a number of ways by design.

    Realism is usually faked to a large degree You find that sweet spot between the look you really want and the amount of control you need overall for gameplay reasons.

    I would encourage you to just open source your approach. This isn't something you are going to be selling for any money really it's too niche even if you make it work., and that way you could get better feedback from people experienced at making games.
     
  35. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,135
    I'm happy to pay for this, you can still have payed asset with source available. we all know this. :)
     
  36. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Hello superjayman,
    Thank you for your questions.

    1.Simulation is performed using an own module based on the methods that can be for example found in Robert Bridson’s Fluid Simulation for Computer Graphics.
    2.Particles are rendered with a standard point to quad geometry shader, about 1 million particles (only some of the foam, bubbles, spray particles from the simulation are rendered).
    3.Water surface. For ocean waves the conventional FFT based ocean model is used. FFT is calculated in a compute shader, for rendering the water surface a standard method with tessellation shader is applied (closer to the camera - higher tessellation level).

    What do you think about the proposed method for constructing the shoreline https://forum.unity.com/threads/water-system-based-on-fluid-simulation.504291/#post-3310281

    Would it be practical?
     
    Xoduz, sjm-tech and Lars-Steenhoff like this.
  37. SquadraCorse

    SquadraCorse

    Joined:
    May 28, 2014
    Posts:
    12
    The effect is really beautiful. Maybe you could have several quality levels so that people could choose the prettiest waves, or the fastest, or something in between.

    I like your idea of creating a spline in segments to apply different wave behaviors along different parts of the shore.
     
  38. HXCMAN

    HXCMAN

    Joined:
    Feb 24, 2013
    Posts:
    5
    ☝️ most exciting asset ☝️
     
  39. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Here is an example of a curved coastline
     
  40. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    685
    Awesome!
    I can't stop replaying this video again and again!
     
    Last edited: Jan 18, 2018
    Quique-Martinez likes this.
  41. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,105
    That looks really great, thanks for sharing!
     
    Quique-Martinez likes this.
  42. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,158
    That's fantastic . congrats
     
    Quique-Martinez likes this.
  43. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    240
    That looks awesome, looking forward!
     
  44. grimunk

    grimunk

    Joined:
    Oct 3, 2014
    Posts:
    254
    From the gaming side, I can't wait to see these type of effects in games regularly. These type of real-time volumetric effects feel a bit like a kind of holy grail.
     
  45. norby

    norby

    Joined:
    Jul 10, 2006
    Posts:
    268
    Lets bring this to unity :) fantastic
     
    Quique-Martinez likes this.
  46. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,354
    Simulations in game engines fascinate me, both realtime runtime ones and the use of baked sim data. Baked varieties obviously have their own challenges in terms of tools for the baking process, amount of data generated and all the implications that come from dealing with that amount of data. The questions you are asking of potential users on this thread are certainly in tune with these challenges. There is also the successful blending of the baked aspects with whatever dynamic layers people require the system to respond to.

    These certainly arent trivial challenges and they've thwarted my own (not ocean shoreline-related) efforts in the past. Especially data size issues. The increased focus on Unity for non-game purposes does at least offer a reminder that systems that have some impracticalities when it comes to games may still find productive use in other niches.

    I would like to give useful feedback about the tooling side of things. But to do so I first have some questions regarding the overview of the spline & modular method that you provided a while back. I havent quite worked out how to word some of the questions, so I will start with just a couple:

    When you talk about shoreline library items, is this a fixed set of items that come with your asset, or do we select an area of shoreline and it then runs the sim on that chunk, stores it, and allows it to be reused for another part of the shoreline that has same slope and other geometric detail?

    Whats being stored, and to what extent are are dynamic options limited? eg is pretty much entire sim data baked, including an entire time cycle of waves crashing on shore? Limits to ocean roughness/wave height/speed as a result? Or something much more limited such as a frame of flow information over the geometry stored, and some of the sim is dynamic/realtime? I'm assuming that out in the open ocean its realtime FFT stuff, I'm referring to behaviour near and at the shore.

    Thanks
     
  47. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    368
    This looks amazing
     
  48. NHydro

    NHydro

    Joined:
    Nov 12, 2017
    Posts:
    16
    Thank you for your interest.
    1. I think both options should be available (shoreline library, and simulation tool).
    2. Realtime FFT based waves are blended with pre simulated flow in the surf zone. What can be controlled for FFT based ocean model is well known (spectrum, amplitudes). The pre simulated waves can be deformed in space time domain (angle, velocity, height) and of course several datasets can be recorded for the same shoreline segment and then can be used depending on the situation.
    3. In this case construction a shoreline is close to designing a road (drawing a path, choosing building blocks along the path).
     
  49. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    124
    I'd love to see a short video showing you creating a shoreline, adding some pylons/walls along it, and then running in game, to get an idea of the workload involved. I will say it looks utterly incredible.
     
  50. smurfted

    smurfted

    Joined:
    Jan 13, 2018
    Posts:
    2
    What he said.
     
    PeterB, Flurgle and blitzvb like this.