Unity 3d - Liquid Water Effect in 3D

Hello Guys,

I haven't really found any tutorials on this and I am really struggling to get something (even really basic) working.

Example Situation.
There is an empty hole in the terrain and water spawns outside of it. I want the water to be able to flow down into the hole and fill it up. So basically it must be particles that look like water that just gets affected by gravity and looks like they get merged together once they next to each other.

I want it to work similar to Minecraft's water except it won't be so blocky.

Would really appreciate the help

Comments

  • That's not a trivial problem. People have been working on flowing water simulation for ages and their solutions are expensive, especially for general case situations.

    Usually what people do is break what they want to have happen down into slightly more manageable chunks. Like, if your hole needs to be filled with water, spawn particles to emulate a flowing stream, then destroy those particles when they hit a water plane object that you scale up from the bottom of the hole according to how many particles hit it. If it's not a core gameplay thing, cheat!

    If it's a gameplay thing, then you're looking at a thing that isn't easily available in a tutorial somewhere... But keywords to get you looking at the right research papers: Metaballs, fluid field simulation and dynamic water simulation.

    Good luck!
  • edited
    It depends.

    If it's just for aesthetics (i.e. the water flowing doesn't need to be accurate), then you're probably best off putting on your vfx hat and treating it as its different parts. The water that flows in might be a particle system, or a mesh with scrolling UVs, or both. There may be a particle system where the water would splash. There may be another particle system that takes care of the ripples. And a flat mesh with a water shader that's just moved upwards as the hole fills up. You might run water splash simulations in 3D software to use as spritesheet textures for your particles, depending on your art style. This is pretty much what is used in 99% of cases, including in AAA. (How many of those layers you're able to use depends on the platform you're targeting.)

    If it's for realism (i.e. your game depends on simulated physics, like in Where's My Water), then you'll have to look up how to write a fluid sim. This guy has a pretty cool implementation of some of the stuff published in GPU Gems, and you may be able to make it work for water. Or find a GPU Gems/ShaderX/GPU Pro chapter where they've tried doing flowing water themselves. I imagine several people have written simpler fluid sims for mobile games and WebGL tech demos, so I imagine the algorithms to do those kinds of things aren't hard to find.

    [edit] Oh crap, didn't see Danny already replied. XD
  • edited
    If you are using unity then you could use the standard water planes and particles that come with it and do something similar to what dislekcia suggested where the water would "run" onto a plane and you could just Lerp the plane height over time.

    Like this : https://dl.dropboxusercontent.com/u/56011417/Waterfill/WebBuild.html
  • edited
    This is one of the best terrain / water interactions I've seen so far.
    It's pretty temperamental and only works on chrome, but it's amazing.



    http://www.chromeexperiments.com/detail/craftscape/

    Use WASD to move around, click "Water" at the top toolbar and then hold down space while moving your mouse over the terrain.
Sign In or Register to comment.