Search Unity

How to approach a volumetric water in 3D

Discussion in 'Scripting' started by adamTim, Jan 16, 2022.

  1. adamTim

    adamTim

    Joined:
    Oct 18, 2020
    Posts:
    29
    Hi guys, I tried googling and searching for any type of 3D based volumetric water in Unity, while all I was able to find was 2D version of water shader. Is there any way to create a volumetric based water in 3D, which is necessary due to player being able to manipulate with environment in such way where they'd be able to move a wall away and therefore release a huge tank of water outside of its regular area.
     
  2. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    The closest I had achieved in unity was using a particle system that was tuned in a way so that it have the appearance of fluid water.

    I had made a glass bottle filled with a liquid potion before that you could rotate and the water would respond to rotation but I had designed this using a 3D model with bones and weights for the fluid inside which mimicked the liquid behaviour within the space it was designed for. But it was not dynamic.

    the YouTube add that shows the water or lava in that puzzle solver game in 2D where he removes the floor and the lava or water falls realistically I believe is achieved with particle system. But I wouldn’t be surprised if it was just an animation that had been specifically designed for the space.

    It is to note that even using particle system to mimic water is expensive. So I had made a hour glass - the sand timer device; using a particle system in unity. And again we can rotate the sand timer and the particles behave as fluid but on my machine I was only able to have a limited amount of particles before performance hit.

    In some cases it may also be possible for a cloth to achieve this, on one occasion for example I create a raft game where a whale rose up out of the water creating fluid like splash and a huge wave in the water. And this was achieved using cloth.

    in blender there are some great fluid simulations. Again you can design these fluid simulations to the shape you want and either take still frames, or create a specially morphing mesh based on some of the frames and vertex positions produced in the fluid simulation of blender. And then morph a model from one shape to another. But I have never done this before for producing a liquid.
     
  3. adamTim

    adamTim

    Joined:
    Oct 18, 2020
    Posts:
    29
    So there might be an option to try and do it with the particle system? I saw the 2D youtube video, which seemed plausible for this application, and think I might stick to particle effect as there might be just one single way the player would be able to access the hidden water tank. Meaning, it could all be prepared in advance and therefore fake it.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,452
    A lot of 2D fluid simulations in games use a port of LiquidFun.

    I was experimenting with it for 2D physics too a while back.


     
  5. adamTim

    adamTim

    Joined:
    Oct 18, 2020
    Posts:
    29
    Would this work in 3D please?
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,452
    No, it's strictly 2D unfortunately. I only mentioned this as a side note because of the mention of 2D fluid.

    I'm not really up to date on what's available for 3D however it's not clear if you're interested in the 3D surface only or the actual volume itself and some kind of fluid dynamics there. That would likely require a compute shader and limit the available platforms.

    There's obviously a bunch of "fluid" related stuff on the Asset Store. I suspect a lot of GitHub projects too, hopefully with nice licenses.

    EDIT: I reread your original post where you stated a mechanic you want i.e. fluid flow after moving a wall.
     
  7. adamTim

    adamTim

    Joined:
    Oct 18, 2020
    Posts:
    29
    I see, currently I'm trying to think about possibilities and options I'd have for my final uni project for which I want to use this type of dynamic fluid simulation, just like @AnimalMan stated I might use either particle system or currently thinking of creating the whole system in Blender and somehow just import it to Unity.
     
  8. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    So if you have ever played like Half Life - you’ll see they just use a little mesh to represent water flowing from a broken container and then raise a plane of water from beneath the floor. Using bones in this plane you could bend it to make it appear as the water is flowing across the ground before the initial flooding.
     
  9. adamTim

    adamTim

    Joined:
    Oct 18, 2020
    Posts:
    29
    Hmm indeed now that you mention it, I remember seeing that effect as well but I dont have much experience with using bones for water though :/