Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Flowmap Generator: Create flowmaps using a fluid simulation [RELEASED]

Discussion in 'Assets and Asset Store' started by Superposition, Aug 6, 2013.

  1. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Flowmap Generator is a tool for creating flowmaps for use in shaders using a fluid simulation. A flowmap is a texture that contains velocity vectors that can be used to create the illusion of flowing water, blowing sand, etc. Flowmaps can be difficult to create, especially on a large scale. Several tools exist for hand painting the velocity vectors, but this can be time consuming and if the geometry changes it is necessary to repaint the flowmap. Flowmap Generator lets you set up a simulation that can be easily edited and resimulated when needed.



    Features:
    -Control the simulation using fields placed in your scene, such as directional, vortex, and calm.
    -Calculate foam accumulation based on the velocity of the fluid in the simulation.
    -Dynamically updating flowmaps let your flowmap react to changes in the scene. Add and remove fluid, change the scene geometry and move fields around.
    -Render heightmaps from your scene so your geometry will be used in the fluid simulation (Unity Pro only).
    -Import textures as heightmaps, including support for 16bit .raw textures.
    -Support for simulation fluid flowing on surface, which can also be used for other types of flowing substances such as snow and sand.
    -GPU accelerated (Unity Pro only) and multithreaded simulations.

    Several example flowmap shaders are included and many more are available on the Asset Store. I've included a quickstart guide to get you up and running fast as well as a full reference describing all the parameters. Works with Unity 3.5.7 or higher and tested on Unity 4.


    Web demo

    Website

    Documentation

    Purchase on Asset Store
     
    Last edited: Sep 17, 2013
  2. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    I've now released a stand alone version of Flowmap Generator. It includes all the features of the Unity plugin. As it doesn't require Unity, all features that normally require Unity pro are enabled, such as GPU acceleration and interacting with imported geometry. It also includes a 30 day trial. The interface tries to match the Unity plugin as close as possible, so the trial should give you a feel for how the Unity plugin would work. I made some improvements and fixed bugs in the Unity plugin code, and those will soon be pushed to the Unity store package.

    Download the trial here: Flowmap Generator Standalone
     
  3. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    506
    Hi,

    Asset looks great but I was wondering if it is compatible with the Flow asset ?
     
  4. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    I've only tried the free version of Flow, but to get my flowmap textures working for the shader included there requires a little bit of work. That shader uses the blue channel of the texture to mask in the flow whereas the textures from Flowmap Generator either have black in the blue channel (no foam), or the foam mask. To get a texture that works with that shader you could bake the flowmap and height/fluid textures from flowmap generator and paste the green channel (fluid depth) of the height/fluid texture into the blue channel of the flowmap texture.
    Most other flowmap shaders will work correctly without any issues as long as they just read the red and green channels of the texture (and make sure to set the texture to linear, not srgb!).
    Flowmap Generator includes a few sample shaders, but I am planning on writing more. Flowmap Generator also optionally supplies UV offsets to materials to allow for world space projection so the flowmap matches the generator position.

    More documentation will be coming soon. If there's anything specific that doesn't make sense, ask away.
     
  5. ecurtz

    ecurtz

    Joined:
    May 13, 2009
    Posts:
    525
    I noticed you have a river file in the example scenes, is there a webplayer or video of this?

    Edit: I figured out those files are for the standalone editor, which has a free trial - Thanks.
     
    Last edited: Sep 20, 2013
  6. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Yeah, documentation and examples are a bit thin right now. I'm working on the next update of the Unity package and it will include some more example scenes, with walkthroughs, and more shaders that are compatible with Flowmap Generator. If anyone has any specific requests, let me know.
     
  7. MikaelTroc

    MikaelTroc

    Joined:
    Nov 2, 2012
    Posts:
    33
    Can you include the river scene from the standalone for the Unity version ?
     
  8. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Flowmap Generator has been updated to include bug fixes and features introduced in the stand alone application. I've updated the documentation and added a few more tutorials. These include a tutorial for making a river and a walkthrough of the sand dunes example scene. I've also added a number of shaders including a water shader with opaque, edge fade, and depth fog versions. These shaders are untested for mobile and probably only work for desktop builds. For the next release I'm going to try adding mobile versions of these shader, but some features may be too expensive.

    All of the new documenation is included in the package on the asset store as well as here: http://www.superpositiongames.com/products/flowmap-generator/documentation/

    Here's a couple of the new shaders. On the left is an opaque shader there the normal map tiles with the diffuse. This can be used for solid flowing fluids like slime. The shader in the middle is an opaque water shader and on the right is a depth fogged water shader with foam. These shaders are explained more in the shader reference.
    $Shaders_01.jpg
     
  9. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    I've been working on some new features, focusing on fluids flowing on surfaces. Two of the features are residual fluid, which causes the fluid to be attracted to where there's been fluid previously and support for outputting a mask that records the normalized time a pixel first receives fluid. This can be used to animate the fluid's opacity.

    Here's a short video showing these features in action:


    The output that I use for the blood splatter looks like this:


    All the animation is done in the shader. The flowing effect was created by adding a directional force field that covered the entire simulation area. The fluid was pushed in that direction, simulating gravity.

    The flow maps took about 5 seconds to simulate at 1024x1024 using GPU acceleration, but unfortunately simulating using the CPU is very slow for resolutions above 512x512. I'm trying to optimize the CPU simulation path, but it looks like there aren't any quick fixes for that.

    Tiling across the simulation bounds is now supported. This can be used to create a generic tiling raindrop mask for example.

    Another upcoming feature will be presets, so you can save and share settings easily.
     
  10. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    567
    @Superposition : I love this new feature!!

    I've been working with Flow shader trying to get this effect working but no luck. Unfortunately the shader isn't accurate with color direction, so if I want the water to flow straight down my object it just flows diagonal down. I've spent many hours trying to fix this, and have had near enough results but still not good enough.

    I was wondering if this new feature is going to use a refractive or a specular bump?

    An ideal shader for me would be to use refractive + bump specular working off the normal map but without foam.

    Could you make different versions? I think foam is great for rivers/oceans but is not needed for walls or generic objects when the water is flowing slow.

    If it's not possible to have refractive + bump specular, could you just have it with refractive?
    Also no base version as I would like to use this shader on top on another material.

    I think it's brilliant the direction you're going with this. I was totally demotivated after realizing that I wouldn't be able to get a decent water effect on my objects but now there is light at the end of the tunnel.

    Anyway I know this feature is not released yet but I'm off to the asset store to purchase this asset

    Well done!
     
    Last edited: Jan 4, 2014
  11. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Most likely you've forgotten to bypass sRGB sampling. This applies a gamma curve to the texture, which causes the directions to be biased towards a certain direction.


    There is a shader without foam included in the package that has specular with refraction based on the normal map. A list of all the shaders included with some information about them can be found here: http://www.superpositiongames.com/files/flowmap_generator/docs/FlowmapShaders.pdf

    Hopefully Flowmap Generator helps you with your water, let me know if you run in to any problems.
     
  12. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    567
    Superposition I was talking about another flow asset that I was having problems with, not yours.

    I've purchased your asset an hour or so and I like the results I'm getting. The flow direction is working perfect so that's really great.

    I think all I need now is a way to mask parts of the object that's not wet, in other words not effected by specular or flow. I think the new feature shader you mentioned will solve that nicely. Is there any chance I could beta test that shader? I will pm you my invoice No.

    I didn't know you had so many shaders... awesome!! you're definitely 5 stars from me :)

    I'm currently using third party software to create the flow map, as the object I'm working is a pod racer engine and I'm not sure if your flow generator is ideal for that sort of geometry? I will be using your generator for rivers/oceans/sand storms.. you have some awesome tools for that sort of thing.

    Thanks Superposition for this brilliant asset :)
     
    Last edited: Jan 4, 2014
  13. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Glad everything's working :)

    The new shader's not quite ready yet, but I'm focusing more on generating flowmaps than shaders so you might need to write your own for different use cases you might run in to. Flow on top of surfaces often requires a custom shader for the specific situation.

    If you can get a heightmap in UV space you might be able to get some interesting effects. UV seams are a problem though. I'm going to see if I can figure out a way to generate flowmaps on non-flat models, but it's a tough problem to solve. Converting normal maps to height maps using something like nDo might help in some situations.
     
  14. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    567
    Hey Superposition,

    not to worry about the shaders I mentioned. I managed to get the other Flow asset working correctly... it wasn't that the fault was in their shader, it was my fault, I messed up the normal maps..

    Any how I managed to get your shader working really well on my pod, I spent quite a long time trying to decide if I should use your shader or the Flow shader, I chose Flow in the end as they have already implemented the mask.

    I only found one shader of yours that allows transparency, are there more than one? I have my base material as Alloy shader then I add the flow shader on top.

    heres a video showing what I'm trying to do. better play it 1080. Looks better on my desktop.

     
    Last edited: Jan 8, 2014
  15. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Nice!

    Right now there's just one "type" of transparent shader, with either edge fade or depth fog (with distortion). When I finish the new features I'll be sure to include some shaders that support those features.

    How are you combining shaders? Duplicating meshes with the transparent shader applied to the mesh on top, or some other way?
     
  16. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    567
    Right now there's just one "type" of transparent shader, with either edge fade or depth fog (with distortion).

    Yep this is the shader I was using :)

    How are you combining shaders? Duplicating meshes with the transparent shader applied to the mesh on top, or some other way?

    haha I shouldn't of said combining shaders as that's not entirely correct and I don't have the skills to do so. All I'm doing is having two materials..

    1: Alloy shader
    2: flow shader on top.

    Performance is surprising good.

    Ps I've just updated the video, this one shows it better. no point watching it below 1080.
     
  17. l0cke

    l0cke

    Joined:
    Apr 15, 2012
    Posts:
    439
    It would be really great, if this tool would be able also generate water mesh (meshes) based on flow map.
     
  18. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    You mean a mesh that is cut away where no fluid was present in the simulation? That should be possible, but doing it by hand doesn't take too long.
     
  19. l0cke

    l0cke

    Joined:
    Apr 15, 2012
    Posts:
    439
    No, I mean mesh for the water (lake/rivers). Project flow map on the terrain height map and make 2d mesh from these intersections. It can be little bit tricky, because you can make mesh only from border intersection points (water level is flat, it cant copy terrain).

    http://www.superpositiongames.com/wp-content/uploads/2013/09/SurfaceFlow_Large_NoText-300x180.jpg - if you look at this picture, make water mesh from surface of this water.

    Currently we are doing quite big terrain and procedural generation is the only way. We have everything covered except rivers/lakes. My idea is, that I load height map into such tool, I will make some water settings (source, power, etc...) and tool prepares water meshes.
    Such tool would save dozens of hours and the bigger terrain you have, the bigger will be benefit. Any change in water setup (density, source...) and you can regenerate water mashes by one function...I would pay quite a lot for such tool, this is something, what is really missing on the market.
     
  20. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Hmm, that is a tricky problem. I've tried using a vertex shader that samples the heightmap and adds the water depth to set the height of the water mesh's vertices. I got sort of ok results doing that. It should be possible to bake a mesh using that technique, maybe blurring the water depth first to make sure there's not any weird height differences. Cutting away the mesh where it intersects the terrain should also be possible. I'll look in to it for the next update.
     
  21. l0cke

    l0cke

    Joined:
    Apr 15, 2012
    Posts:
    439
    Great, thanks!
     
  22. skeptika

    skeptika

    Joined:
    Dec 31, 2011
    Posts:
    89
    Quick question, do your shaders work on Mobile? I tried your stand alone: http://www.superpositiongames.com/products/flowmap-generator/downloads/

    and while the transparent versions work on desktop, they're breaking for me on mobile? Am I doing something wrong or were these shaders just not designed for mobile? Really cool asset though, and the trial is something more Unity assets should consider, gives you a really good feel for the power of the asset!
     
  23. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    The current shaders are completely untested on mobile. It should be possible to make something that does work, and it's certainly a priority for future releases.

    Something to keep in mind with the stand alone is that it includes features that require Unity pro when using the Unity plugin from the asset store. The most important being GPU acceleration and support for rendering heightmaps from geometry. If you don't have Unity pro, make sure to double check the features that are most important to you are available when using Unity free before buying.
     
  24. l0cke

    l0cke

    Joined:
    Apr 15, 2012
    Posts:
    439
    Any progress? :)
     
  25. XMachinaX

    XMachinaX

    Joined:
    Dec 29, 2012
    Posts:
    147
    Hi could you perhaps post a step by step tutorial on how to convert Flowmap Generator flowmaps to Flow shader flow maps. I know you mentioned it in a previous post but a full organised step by step would really be amazing as I am still a bit confused on where what channel should go/should be changed to.

    Thanks in advance for any and all help and advice.
     
  26. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Hi XMachinaX, I've only tried the Free version of Flow, but when editing the materials included the flowmap texture input says "FlowMap(RG) Alpha (B)" which would mean the Red and Green channels correspond to the flowmap directions. This is exactly how Flowmap Generator works, so no changes needed there.

    Flowmap Generator has an option under the Shallow Water Simulator script called "Write fluid depth to alpha". This is used when simulating water flowing on a surface (check the River scene, found in the Examples folder). To use this texture with Flow you'd want to move the data in the alpha channel to the blue channel.

    When "Simulate Foam" is enabled, Flowmap Generator writes the foam mask into the blue channel of the flowmap texture. There is also an option for writing the foam to a different texture (Output Foam Separately).

    If "Output High/Fluid" is enabled, Flowmap Generator will output a texture that contains the fluid depth at the current simulation frame in the green channel. Sometimes this output works better than the averaged fluid depth that is written into the flowmap texture's alpha.

    Hopefully that helps.

    Was that you that posted on the asset store page? The focus of this package is creating the flowmaps. The shaders included are more to give an idea of what's possible with flowmaps rather than something that's ready for using as is.

    On that note, I probably won't be adding support for creating a mesh based on fluid depth. That feature seems outside of the scope what I'm trying to do with Flowmap Generator. I've been focusing on better support for fluids flowing on surfaces, hopefully I'll have something to show soon.
     
  27. XMachinaX

    XMachinaX

    Joined:
    Dec 29, 2012
    Posts:
    147
    Hi,

    We are sitting with a little problem. It seems that the colour of the
    water where the edge fade starts is a very dark blue, now we are using red bloody
    water and the blue edge fade is looking a bit awkward is there any way to change
    the colour of the edge fade?
     
  28. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,864
    what type of mesh does it use? is it OBJ? I tried to import an FBX, but it didn't appear... :(
     
  29. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    Yes, only .obj meshes are supported in the stand alone version.

    The Unity plugin version uses any mesh that Unity itself can import.
     
  30. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,864
    Right... pitty that's so, since most of my meshes are .fbx. at least I have my original .blend files to use! :)
     
  31. loko08

    loko08

    Joined:
    Oct 6, 2013
    Posts:
    38
    Hi Superposition!

    I just purchased the flowmap generator, I was wondering if you had or could point to a video tutorial on how to use the unity plugin, I tried following the pdf's but they seem very ambigous, I am trying to setup an scene with a river that goes through a lake and then keeps going.

    Thanks in advance!
    JP
     
  32. Katarak

    Katarak

    Joined:
    Feb 19, 2013
    Posts:
    13
    Hi Superposition,

    does this plugin work without issues on Unity 5?
     
  33. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    I haven't created any video tutorials and I'm not aware of any existing. What exactly do you find ambiguous about the documentation? Have you tried following the River Tutorial? To create a lake connected to a river you would just make a wider area of open water where you want your lake to be. Make the ground flat where you want the lake to be and sloped where you want your river to flow.


    I don't have Unity 5 so I'm not sure if there would be any issues. The full source is included with the plugin, so it should be possible to fix any compatibility issues if you feel comfortable editing the source code.
     
  34. loko08

    loko08

    Joined:
    Oct 6, 2013
    Posts:
    38
    Ok, I tried following the river tutorial, but I can't really understand where am I supposed to set a lot of stuff, for example I see that there's a plane that contains the actual river, and this plane has the same size as the terrain. On my case, I have a very big terrain, so I wanted the river object (the one that would have the shader ) to be just as wide as the river, I don't really understand how to do this.

    Thanks in advance!
     
  35. Superposition

    Superposition

    Joined:
    Jul 18, 2013
    Posts:
    20
    The plane is just used for baking the flowmap to a texture. You could make the plane only large enough to cover your river and bake your flowmap. Then unwrap your river mesh using a planar projection that matches the size and position of the Generator you used to create the flowmap. The river mesh will then be able to use a material that uses that flowmap texture and the generator can be hidden or deleted from your scene.

    It's not the best workflow and probably something that should be improved in future versions.
     
  36. loko08

    loko08

    Joined:
    Oct 6, 2013
    Posts:
    38
    Very well!
    I will give it a try, and then if it doesn't work I will come back :)
     
  37. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    256
    Can you please confirm if this fully works with Unity 5? If not, is there an update planned? Thanks
     
  38. Rave-TZ

    Rave-TZ

    Joined:
    Jul 21, 2013
    Posts:
    43
    Tried this in Unity 5 and it works. Got a warning when I got it saying it may not be compatible since the last update worked with Unity 3.

    Right now I'm trying to find a solid way to add mirrored reflections.
     
  39. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Hey there! I was looking at writing something like this myself as my needs don't really fill the full feature set of this asset but this does look very good. I have a few questions however.

    I'm assuming it creates a flow texture, does this spread across multiple UV islands in the case of a river where it makes sense to chop the river surface mesh up so it's uvs fill space efficiently? In fact following that, could it simulate the flow of an entire river network and tributaries from their high inland source to one large sea level delta including obstacles abd modifiers based on river width, depth steepness and so on?

    And I suppose finally does it seem reasonable to sample the flow textures for certain situations like sharp velocity, height or direction changes so particle systems and such might be spawned here? I'm thinking along the lines of using this kind of mentality to create metadata that can affect ai and environment behaviour procedurally

    Thanks for your time
     
  40. Labyrith-Studios

    Labyrith-Studios

    Joined:
    Mar 3, 2014
    Posts:
    1,278
    I have just purchased this and I have a few issues so far:

    1) Haven't a clue how to use effectively, documentation needs redoing, or videos made
    2) When I create a new field, I just get a white square, no graphic with arrows so I can't even see what is happening
    3) The water seems very random, I get waves appearing without any fields

    I am using this in an underground sewage area btw.
     
  41. JesseAlexander

    JesseAlexander

    Joined:
    Nov 22, 2009
    Posts:
    287
    can this be used to generate flowmaps at runtime? (not necessarily "play time" but we have an in-game level editor which we want players to be able to create rivers, and then bake the flowmap from there