Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

FLOW ️➖ Fast Fluids

Discussion in 'Assets and Asset Store' started by Darkcoder, Jul 10, 2021.

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406

    Cover.png

    FLOW allows you to add large scale interactive fluids to your scene - all highly optimized using GPU acceleration.

    >> Get FLOW <<
     
    Last edited: Aug 15, 2021
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Placeholder
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Hey everyone,

    FLOW Version 1.0.0 has now been released on the asset store!

    There are many more features I wanted to add, but I think the core functionality is already really good so I went ahead and published it. You can also get it 30% off during the first 2 weeks.

    Here are some things I will experiment with and hopefully add to the asset soon:

    • Ocean Wave Simulation - Right now the fluids flow down and settle, unless you add more fluid or move objects to disturb it. This can make the scene look boring after a while, so I plan to implement some method to constantly 'disturb' the water to add waves that appear from the edges, or perhaps some user-defined area.
    • Save / Load - Right now there is no way to save and load the current state of the fluid simulation, which I plan to implement soon.
    • Better Underwater Rendering - Right now the underwater rendering is basically just depth fog. I plan to experiment with some kind of refraction/distortion effect, as well as perhaps some kind of underwater bubbles or debris look.
    • Better Particle Rendering - Right now the fluid particle system linearly scales the particles based on the volume of fluid they contain, and they only add fluid to one fluid column. This looks great in some scene setups, but not so good in others, so I plan to add more options to make it look good in more scenarios.
    • Infinite Edge Rendering - Right now the fluid can only appear in the specified simulation boundary size, which is a fixed box shape. This means your fluid can look like a square if your camera view distance is high enough. While it's not possible to make the fluid simulation infinite in size, I plan to experiment with ways to make the edge of the fluid boundary extended forever so it at least looks like it is infinite. Then you can use gameplay tricks to keep the player inside and it still looks immersive.

    Let me know if you have any other ideas that I should consider implementing.

    Also, since this is a new asset there may be some issues/bugs that I missed, so please let me know so I can fix them!

    If you've purchased the asset then please consider writing a review, it really helps me out, especially for new assets!

    Enjoy :)
     
    Automatanism and knxrb like this.
  4. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    207
    Does the video show any mobile demo? If not, then can you provide a mobile demo? or an apk so i can test.
     
  5. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    32
    Hay. There is the sample tool thing, but can it read what kind of fluid is in question and then call some function or alter variables in some script? For example, could you make character slip in mud? Thinking about the potential in some kind of cleaning game. And possibly for cooking by mixing different fluids? Also there's the mention it can't go through pipes and such. How well would it work with indoor scenes and would stairs and multiple floors cause huge problems. Also does it support HDRP? Meow.
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    All features should work similarly on Mobile, but since they have lower GPU power you would want to use a lower fluid Resolution setting. You can get a test APK HERE.

    This is the large terrain demo scene (1km * 1km) with the terrain triangle count reduced, a fluid resolution setting of 0.1, and the FlowManager component's UpdateMode set to Every Other Frame (default = Every Frame). This runs well on my Galaxy S6 test device (6 years old). For more modern mobiles you can of course increase the resolution and simulation framerate.


    If your scene contains multiple fluids that mix then it's not always possible to tell you what fluid is what, since the sampled fluid can be in any mixed state. However, I could make some sort of component that allows you to specify a list of potential fluids, and it could tell you which fluid is the closest match based on a threshold value you specify. I've made a card for this HERE, I'll see if I can add it in the next version maybe in a few days.

    Indoor scenes can work, as long as you set the simulations HeightMin/Max to cut off the roof of your building(s), otherwise the fluid would appear on top. Or, you could set it up so the ceiling/roof has no colliders, and only the walls do, then it should more or less work.

    Keep in mind the fluid is simulated using vertical columns, with one at each x/z point. If you need multiple floors then you could have one simulation per floor, but fluid from the above floor would not be able to interact with the one below it.

    However, if the floors in your scene don't overlap and from a top-down view it effectively looks just like a 2D map, then you could use one simulation for the whole level and fluid will be able to flow through it. Just think of the fluid as a terrain with a heightmap, it has the same limitations.

    Yes, it should work in the standard pipeline, URP, and HDRP.
     
    Last edited: Aug 17, 2021
  7. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    32
    Sounds interesting. I wonder if fluid that spills over the object could be turned into droplets or the things those cannons shoots in the demo? That way they could maybe change the simulation they are part of? Can you say how many simulations per scene would be viable? Might go bit out of scope of this asset here.

    //Edit: One thing I'm also thinking about is blood for some kind of adventuring/fighting/RPG thing and there could also be water, mud, slime and whatmeow and those would affect movement in different ways.
     
    Last edited: Aug 17, 2021
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Turning fluid into particles would be nice, but as far as I can see there's no good way to do this using a GPU implementation. The fluid is basically a 2D array of data, and the particles are a 1D list, and you need to be able to selectively write between them without overwriting particle data.

    There are some papers online that demonstrate this ability, but they operate entirely on the CPU which makes this trivial. When developing FLOW I experimented with a CPU only fluid simulation using Jobs + Burst, but the performance wasn't even close to what it was on the GPU so I scrapped it. Updating the fluid simulation itself can be done on the CPU, but sending the data to the GPU to be rendered made it impractical, even on a high end desktop.

    To implement it on the GPU, there would need to be some kind of atomic counter so each spawned particle is given a unique ID. As far as I'm aware this is only possible using compute shaders, but compute shaders have pretty limited platform and device support, so I don't consider it an option.

    One alternative is to copy the fluid data to the CPU and then detect where particles need to spawn, but sending this much data from the GPU to CPU is too slow. Another alternative is to make the particle buffer so large that an atomic counter isn't required, but this means updating the particles will slow the whole simulation down, so it's not viable.

    If anyone can think of an alternative approach that doesn't have any of these negatives then I'll look into it.

    The only semi viable approach I can think of is to generate the particle ID using a hash of the fluid column coordinate, and to modify the hash if a particle already exists there. The main downside to this approach is that it's not possible to know if a particle was written in the current timestep, so it's possible to 'lose' fluid over time if enough particles get spawned. Perhaps this loss is worth it though, we could call it 'evaporation' :D


    The amount of simulations doesn't matter so much as the amount of fluid columns in all of the simulations combined. Also, each particle belongs to one simulation, and there's currently no code to allow them to switch simulations (though it would be possible to implement).

    Your game scenario can already be implemented with one simulation. For example, you could add the FlowSample component to your character, and adjust the Rigidbody's Drag based on the Viscosity of the sampled fluid.
     
    Last edited: Aug 18, 2021
  9. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    32
    Thanks for the answers. Maybe there could be samplers at the edges which would then generate droplets and activate drains somehow, but might get overly complex and not work very well.

    Maybe it would be best to stay in use cases that uses the strengths of this asset. Meow.
     
    Darkcoder likes this.
  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Oh I see, I thought you were talking about crashing waves and other scenarios you might expect to cause particles to spray up.

    Making water flow off the edges and turn into particles is a little easier to do, but is basically the same issue. I plan to make some kind of drain component that tells you how much fluid was drained, that way you can spray particles or do some other gameplay stuff. This would still require data to be sent from the GPU to CPU though, which is too slow for every single point along the edges.
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Hey everyone,

    Version 1.0.1 of FLOW is now out!
    • Added Trigger / Fluid demo scene.
    • Added Paint Fluid demo scene.
    • Added FlowSample.OnSampledNothing event.
    • Added FlowSampleFluid component.
    • Added FlowPaintModifier component.
    • Fixed gc alloc from FlowSurface component.
    • Fixed gc alloc from FlowParticles component.
    • Fixed gc alloc from FlowUnderwater component.

    You can now:

    DetectFluid.gif
    Detect what kind of fluid is under a specific point.


    PaintFluid.gif
    Paint fluid with your finger/mouse. This also works with draining fluid, adding forces, etc.

    Enjoy :)
     
    PutridEx, knxrb and Aetherial87 like this.
  12. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    32
    If I'm not thinking things totally wrong, would putting the resolution to 10cm allow the simulation to work on 100m^2 area on entry level PC? And could you make the simulation area to follow the player without any problems? Thinking about blood and small puddles which could benefit from having more dense grid.
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Sure, it's the same amount of fluid columns so it will run the same. The exact performance depends on the amount of features you enable (e.g. Wetness, Particles), how heavy the rendering of your scene already is, and the pixel shader performance of your GPU.

    Also keep in mind the ground height data will need to be recalculated if you move the simulation, which is currently recalculating everything. Even if I implemented the ability to 'shift' the data, and only recalculate the newly appearing areas, this is likely to cause stuttering in your game as it has to perform a lot of raycasts. Since the height data is stored in a texture, the best solution would be to generate a high resolution height data texture ahead of time (e.g. edit time), and then paste sections of that into the simulation height data as you move. This would run very fast, but it would also require quite a bit of custom code to set up. Maybe in the future I will add a feature like this, but it's relatively advanced and I don't think many people would need it so it's not a high priority.
     
    knxrb likes this.
  14. CitrioN

    CitrioN

    Joined:
    Oct 6, 2016
    Posts:
    90
    Is it possible to have the liquid slow down enough using the viscosity feature so it would stick on walls simulating things like blood splatter etc?
     
  15. hncarlos

    hncarlos

    Joined:
    Dec 21, 2012
    Posts:
    12
    Hi

    looks awsome!

    I have one question, besides the simulation of fluids, is it possible to make mechanics like From Dust, especially adding and removing terrain at runtime with erosion (minute 2:10)?


    if so, i will buy immediately! hehe

    anyway, looks pretty good!
     
    Last edited: Aug 20, 2021
  16. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    could i put fluids in containers with measurements?
    could i be able to save the info about how much fluid is where? , to reload in new gaming session?

    i can pour and sprinkle yeah?

    looks great

    i want to make a gardening game some time with cool water
     
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    The viscosity can be set all the way up to 1, so the fluid stops moving. However, keep in mind the fluid is simulated using fluid columns. This means you can't just place some fluid anywhere on the wall, it would have to come up from the ground height up to where the fluid height is, and can only flow down & out to surrounding columns.


    No erosion is supported, because sending that much data from the GPU to CPU is very slow. Plus, updating the whole terrain every frame the fluid flows would be too slow for Unity to handle. To implement erosion that runs fast, a custom terrain solution would need to be implemented that does everything on the GPU. Maybe in the future I will consider this, but it's probably more work than making FLOW itself, so it would probably be some separate extension asset.

    You can modify the terrain and have the fluid react to the changes though, you just need to call the FlowSimulation.DirtyGroundAll(Vector3 worldCenter, float worldRadius) method after your modifications.


    You can fill areas of your map with accurate amounts of fluid, and you can sample the depth of fluid at specific points. There's currently no ability to detect the exact volume of water in a region though.

    There's currently no ability to save/load the fluid state, but this will be implemented soon.

    You can't fill a moving 3D container with fluid and then pour it out, that would require a particle based fluid simulation (e.g. Obi Fluid). FLOW simulates using fluid columns, kind of like a heightmap, and the fluid flows on top of a heightmap generated using raycasts, so it's not suited to moving containers and such.
     
  18. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Maybe this idea is too weird, but can you reverse the direction of the fluid column, and slow it, then freeze it, to get icicles?
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Hey everyone,

    I've been working on a new way to store fluid data that allows for better precision when mixing colors and such, and it seems to work really well - especially on mobile devices that don't support high precision floats in shaders.

    This change also frees up space for up to 3 extra fluid parameters, so I was wondering if anyone has any ideas as to what I could use these for?

    Currently there is: Color, Opacity, Smoothness, Metallic, Emission, Viscosity, Foam.

    The only thing I can think of is temperature, but even that's not so useful since you can already use Emission to make things glow.

    Maybe I should just leave 3 'custom' properties, so you can use them for anything you like?

    For example, you could use one to store 'nutrients' for use in a farming or fishing game and have some custom logic that performs actions based on that. You could do something similar to store 'pollution', etc.


    This would be possible with some modifications to the surface shader and the fluid physics code, but not with the currently available settings.

    I already have some (not activated) code that allows for different kinds of interesting simulation physics, and I plan to allow you to choose between these somehow. I also plan to improve the surface shader code to allow for more visual styles, and something like what you describe should be easier to implement with these changes. I've added it to the to-do list HERE, just keep in mind these other features have a higher priority :D
     
    Haxel0rd, hopeful and PutridEx like this.
  20. hncarlos

    hncarlos

    Joined:
    Dec 21, 2012
    Posts:
    12
    Hey!

    just bought your asset... still playing around with the tools.. but looks sweet!
    i have some questions that i do not found in docs, maybe i misread it, than you can point me out, so:

    1)i'm missing some density settings.. one of these 3 properties could be density, to make some fluids be on top of others.

    2) what would be the best approach to make the simulation inside a empty bottle or a snowglobe? is it possible at all?

    3) right now the simulation area is defined by a cube or rectangle, is there any way to make a sphere? (i want to make a round diorama)
     
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    1 - Each column of fluid can only store one set of data (e.g. Depth, Color), so there is no being on top of one another. The Viscosity setting can be used to control how quickly they mix, but that's about it.

    2 - The fluid flows on top of a heightmap, so at best you can only have the bottom half of a globe or bottle. Once you reach the top half, the container shape would start narrowing which is not possible to represent using a heightmap.

    3 - You can use colliders in the shape of a circle to make the fluid only flow in the circle region, and this same idea could be extended to any 2D shape. A sphere isn't possible though, only the bottom half of a sphere (dome).

    The diorama style edge cutoff used in many of the example scenes is only possible with rectangle shape. In the future I may experiment with different shapes, but it will likely require a completely different technique to render.
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Hey everyone,

    For fun I decided to make a video showing what the classic Breakout game might look like with ludicrous amount of fluids using FLOW, enjoy :)

     
  23. CncDad

    CncDad

    Joined:
    Dec 14, 2019
    Posts:
    1
    This is really neat! I notice that FlowSimulation is partly ignoring its own transform. It's using x and z to determine the bounds, but using heightMax as an a absolute y coordinate for raycasts (and translating the world y coordinate of the hit back to a height value), so it only works as expected when transform.y = 0. Similarly, raycasts are in the direction of Vector3.down, as opposed to -transform.up. Aside from the raycasts, which are trivial to change, this works fine in a relative reference frame, which opens up a lot of fun possibilities.
     
    hopeful likes this.
  24. FelDagaroth

    FelDagaroth

    Joined:
    Jun 23, 2021
    Posts:
    8
    I purchased this in hopes of making blood pools that would grow after a mob is dead, but am having a lot of trouble getting anything approaching a realistic look without 'scintillation' or very pixelated edges. I tried emailing a while back but never heard back, so I took the gamble that it would work. I'm testing in just a small area, but even then if I push up the resolution it crashes. I'm also having a hard time getting the surface and material to work well for my needs. Any suggestions/help/demos would be greatly appreciated!

    Edit: this is the closest I've gotten, but would like to be able to control the transparency if able. If it is enabled, it becomes clear enough to be water. Also, any thoughts on how to make this actually interact with the floor rather than just be placed at the same Y? flow.PNG
     
    Last edited: Aug 27, 2021
  25. Mugamoomoo

    Mugamoomoo

    Joined:
    Jan 2, 2018
    Posts:
    2
    Probably going to buy this asset tonight. I would really like to see the infinite edge rendering implemented but, I would imagine you must first work on the serialization and saving. Anyways, great job on an amazing asset! Also, is there a way for water to flow in a concave scenario?
     
    Last edited: Aug 27, 2021
  26. lloydhuang

    lloydhuang

    Joined:
    Feb 2, 2019
    Posts:
    12
    hi,I bought your asset few days ago, and i email you 2 days ago, did you receive my emial? (via magneteye5360538@gmail.com)
    if not, please send me a email ?
     
  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Good point, I don't think I ever tested it with different Y positions, I'll see what I can do for the next version!


    I just checked the spam folder and I see your email there. I can reply here though.

    Do you have a reference image or video of what you want it to look like? If so I can experiment on my end and see what I can come up with. It's possible the effect you're after requires modifications to the surface shader. Right now it's only implemented with basically 2 styles, so I'm interested in seeing what other styles it would need to support.


    Thanks. For the next version I'm actually working on changing the way the fluid data is stored so it can mix with higher precision, because right now it doesn't behave so well on older mobiles which only support half precision floats. That's almost done though, then I can work on the other more fun parts :)


    I just checked the spam folder and I see your email there, I'll reply now!
     
    FelDagaroth likes this.
  28. FelDagaroth

    FelDagaroth

    Joined:
    Jun 23, 2021
    Posts:
    8
    Here are a few examples for material and style (though the goal is pools that could be up to a few meters wide depending on the size of the mob). There will be separate decals for splatter. It would be great if the pool could 'react' to the floor rather than just be a circle as well. Thanks ahead of time for your help!


    https://www.pond5.com/stock-footage/item/81453009-female-hand-touches-pool-blood-wood-floor
     
    Last edited: Aug 27, 2021
  29. Mugamoomoo

    Mugamoomoo

    Joined:
    Jan 2, 2018
    Posts:
    2
    Will the data handling be a long term solution once it is updated?
     
  30. HolyFireGames

    HolyFireGames

    Joined:
    Apr 23, 2014
    Posts:
    134
    Hey, just purchased today, very cool asset. I have a couple of questions:

    Is there any way you could add the ability for having custom interactions between fluids? For example, two different fluids hitting each other and causing damage to one another, draining one of them.

    Is there any way to know the deepest fluid area around a game object so the game object could target that location with a drain or add effect?

    Thanks
     
  31. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Hi, I'm trying to integrate your awesome looking asset into my offroad vehicle game. I have simulation space, when a vehicle drives through the fluid it has really "unsmooth" edges etc, see sample video:



    Is there a way to make it look less jagged around the vehicle, just smooth waves/forms when the vehicle drives through?
    Looks like something is vibrating a lot as it goes through.. how can it be smoother?
    I have tried adding various simple primitive shapes in the vehicle and adding the flow object script, changed that to various sizes but the result seems the same.
    Maybe I need to set layers so that only the flow object in the vehicle affects the water?
     
    Haxel0rd likes this.
  32. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Ok, I think I "fixed" this, I just had to look at the pirate ship demo use some of those components, I think I can get my vehicle to work nicely now. But I see another thing, can I ask your input on this, the fluid s not rendered nicely further away, any ideas why that might happen?
    Capture.PNG
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Thanks, I'll see what I can do.


    Yes, it will improve the simulation quality for all devices, and also allow for even higher precision color mixing for projects that require it.


    1 - It's possible to implement, but it depends how you'd want it to work in terms of user settings.

    In the next version you will be able to specify up to 3 custom fluid parameters. So let's say one of those settings is 'strength'. It would be possible to make a custom fluid mixing algorithm that made it so when a high strength fluid hits a low strength fluid, the mixing discards fluid based on the strength difference. Would this be good enough for your scenario?

    2 - Currently you would have to place FlowSample components around your scene, and check through them all to find the deepest. This might become slow if you have too many of them though. To efficiently find the deepest point, the depth checking would have to be done entirely on the GPU so it just copies one value to the CPU.

    I've added this to the todo list HERE. just keep in mind this is a little tricky to optimize for large sample sizes, because reading every depth value per frame is likely to be slow for large simulations. To speed it up it would have to be spread over many frames, which makes it trickier to implement and therefore lower on my priority list.


    The issue here is that the fluid flows over a heightmap representation of your scene, and with your vehicle this is the highest point on your vehicle. Since the simulation is split up into columns with a fixed separation, every time your vehicle moves far enough to enter another column, it's like a 'wall' suddenly appears there. This causes the fluid to suddenly shift up a lot in height, which in turn causes it to violently splash down in the next few frames.

    This is a scenario I didn't actually consider, and your results look better than I would have expected. I think the best solution is some way to mark objects as being 'dynamic' like this, and instead of the heights snapping to what was found, it gradually transitions there. I've made a card for this HERE, and I'll experiment with this soon.

    One thing to keep in mind is that even if this solution works, the end result may not be as good as you want. It might be better to exclude the vehicle from the FlowSimulation ground layers, and instead use FlowFloat to make it have drag when inside fluid, and you could disturb the underlying fluid using FlowModifier's AddForce (similar to the Island demo scene with the ship). In the future I want to make a more advanced version of this modifier though, so you can for example move an object from A to B, and it will automatically disturb all fluids between them. The FlowModifier approach I mention is a bit of hack currently.


    Aha yes you figured it out as I was typing :D

    What kind of camera range is this issue occurring at? I've noticed some issues with the depth calculations at distances of around 500 units+ that I plan to look into.
     
    PutridEx and khos like this.
  34. HolyFireGames

    HolyFireGames

    Joined:
    Apr 23, 2014
    Posts:
    134
    Thanks, I think that would work for the first question. I have a few mobile games in mind where I want the fluids to interact based on team colors, so as teams upgrade their strength the way their fluids interact would need to change based on that strength. As players continue to upgrade and attack the other players fluids one team could overcome the rest.

    For the second question, my game wouldn't have huge scenes like big terrains. I'm mainly looking for a way to have units that can target their enemies deepest liquid points and bomb them as a way to effectively target areas they should attack. For turrets, once it's triggered that fluid is in their area, I would like the turret to target the deepest point that is within it's reach.

    Those are the use-cases I have in mind, nothing on a huge scale terrain wise or anything.

    If there a way we could fund development towards specific items on your TODO list to make it more worth your time and effort to get them done?

    Thanks!
     
  35. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Cool, thanks!
    Here is what I have currently,

    Would welcome your input on what you think of this, I think it looks quite convincing, still need to try work out how to use my water shader, make floating vehicles work, but I think this is a rather nice asset.

    Regarding camera range, I use 400 for far setting, but I have tried changing every camera setting, nothing helps with that graphic artefact yet.
     
  36. HolyFireGames

    HolyFireGames

    Joined:
    Apr 23, 2014
    Posts:
    134
    That looks really great, nice job!
     
    khos likes this.
  37. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Cool, thanks :)
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Hey everyone,

    Version 1.0.2 of FLOW is now out!
    • Renamed FlowPaintModifier component to FlowPaintScreen.
    • Fixed Paint Fluid demo scene touch controls on mobile.
    • Added Viscosity reading to FlowSample component.
    • Added Custom1/2/3 settings to FlowFluid component.
    • Added Advanced / CustomData setting to FlowSimulation component.
    • Added Advanced / PrecisionA/B/C/D/E/F settings to FlowSimulation component.
    • Rewrote fluid data storage code to be more flexible and improve precision.
    • Improved particle simulation performance.

    The new data storage system seems to work really well, and it has the same performance as before. The fluids now flow and mix really well on my Galaxy S6 test device, which is notorious for causing issues when it comes to shaders. This also improves the fluid mixing quality. For example, the "04 Fluid Types" demo scene used to have an unexpected red color appear when the honey would mix with the mud, but this is no longer the case.

    Anyway, let me know if you encounter any issues, enjoy :)

    I'll reply to the questions a little later, I have to go out now.
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Ah interesting. Well I can implement some of these as examples, but I don't think there's any way to make the settings flexible enough to work for all fluid interaction scenarios. The best solution is for me to just tidy the fluid simulation code a bit and make it so you can easily choose between multiple simulation variants, and then everyone can implement their own custom code in an ideally simple way.

    In your bombing the deepest parts scenario, using FlowSample may be the best solution. For example, you could just move the same point(s) around to 'scan' for the deepest part. This would take some time, but maybe that's a good thing if it's for AI or something? You could also pre-process the scene height data to find all the heightmap local and global minimum points.

    The best way to get me to implement something is to keep reminding me how important it is :D



    Looks great! Indeed, I still need to do some work and find a more convincing way to make a 'wake' as objects move through the fluid.

    I did a little more digging into the draw distance issue, and it seems like the camera's near clipping distance is the culprit. The lower I set this, the more the fluid depth rendering appears to break. This should make debugging this easier.
     
    khos likes this.
  40. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Thanks, I'm actually quite happy the way it works currently :)

    Two issues stand out for me currently:
    -How to use my own water shader, would welcome any guidance you can offer here, I'm using Lux Water, it offers foam and transparency, can I Lux on your asset?: Screenshot of what I have currently:
    upload_2021-8-29_16-26-22.png

    -The clipping thing, I have tried all sorts of things (camera near clipping value, graphics settings, render mode, quality levels) in my scene, nothing changes it. I noticed it shows in the scene view too, screenshot:
    upload_2021-8-29_16-23-21.png
    Is this some kind of hardcoded value in your asset perhaps?

    I have other vehicles that float, those seem to be working quite well.
     
  41. OdderOtter

    OdderOtter

    Joined:
    Aug 16, 2015
    Posts:
    44
    Howdy!

    I also attempted to use another water shader (Crest) without success and was wondering if you could help provide some guidance / documentation on the topic?

    Based on the demonstration video ~ 6s - 9s it seemed this was possible. If not, no worries. I bought it without that documentation being present. ;)
     
  42. TomGa83

    TomGa83

    Joined:
    Jul 31, 2021
    Posts:
    4
    Could someone point me towards (or make) a video off the first few steps of how to set up please?

    I just really can’t get water levels right.

    Also, can the level start full or does it always fill up?
     
  43. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    The fluid surface is rendered using a special shader that displaces the mesh and colors it based on the fluid data, therefore it's not possible to use Lux Water or any other water shader without combining their functionalities. The shaders in FLOW are made using the Better Shaders asset, which can allow for easy combination of shaders as long as you have Better Shaders, and the other shader is also written in Better Shaders, but I imagine that's not the case, so it would probably be very difficult.

    You can try adjusting the Range Min/Max values in the Surface material. One thing that's hardcoded is the ray marching of the fluid surface shader to find the optical depth. This is limited to 100 iterations, with an initial step distance of 2 units. It looks like this might be the cause of the issue you see.


    The water seen at 6-9 seconds is the fluid Surface shader that comes with FLOW. See my response above for why it would be difficult to integrate with Crest.


    What's wrong with the text guide HERE?

    The simulation starts with no fluid, you must add it via modifiers or particles. You can see the "Island" and "28 Add Fluid Below" demo scenes for how to initialize the fluid at a specific level.
     
    khos likes this.
  44. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Thank you for the info.
    Is the FLOW shader able to set transparency? Can this be considered for inclusion in a future update if not currently available?
    Regarding the 2nd point, can this be considered for inclusion in a future update where e.g. you can adjust yourself, instead of a hardcode value, ideally not see the artefact.
    Many thanks.
     
  45. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Normal transparency wouldn't work properly because the fluid is one very large mesh that can easily deform in such a way that multiple fragments overlap per pixel. This would cause the fluid fragments drawn after to appear on top of the previous fragments, even if they are farther away from the camera. There's no (fast) way to avoid this, which is why I use the opaque/grab texture style transparency. This still doesn't correctly combine multiple overlapping fragments, but it at least always draws the closest fragment which is usually good enough.

    Yes I will add more settings to the shader in the future. I still need to experiment to find the cause of the issue, as I'm just speculating that these values are causing it. Does the issue you experience happen in the "Large" demo scene too? I'm having difficultly replicating the exact issue you're seeing.
     
  46. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Thanks for your reply, it's a bit odd, if use your large demo scene it seems ok, even if copy/paste all of other scene's objects (other than camera) it still seems to work, if enable my camera in your demo scene it seems to work also..

    hmmm not sure what to make of that yet. Anyway, if you are open for me to do some testing etc let me know.
    Maybe I should take your demo, put it it my scene..
     
  47. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Soo, I may have tracked down what affects the graphics artefact:
    Transparency-on.PNG
    Transparency-off.PNG

    Not sure if this helps to investigate/update things?
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    Yeah it looks like my depth fog calculations are incorrect, I'll fix it and send you an updated build shortly.
     
    khos likes this.
  49. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Thanks, I'll try it asap and provide feedback
     
    Darkcoder likes this.
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,406
    One issue I just considered with the new depth calculation code is that it won't work with submerged objects unless they are part of the fluid simulation's ground. I can fix this though, so for now please ignore that little issue :D
     
    khos likes this.