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

Surface Waves - Dynamic Rivers, Lakes and Oceans

Discussion in 'Works In Progress - Archive' started by RC-1290, Jun 6, 2014.

  1. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Hi,
    Just imported alpha 3 into a 2017.2.0b11 project and get these errors:

    Assets/Code Animo/CustomMaterialEditor/Editor/CustomMaterialEditor.cs(92,61): error CS0266: Cannot implicitly convert type `UnityEngine.Rendering.TextureDimension' to `UnityEditor.ShaderUtil.ShaderPropertyTexDim'. An explicit conversion exists (are you missing a cast?)

    Assets/Code Animo/TextureDebug/Editor/TextureAnalyserWindow.cs(376,70): error CS0266: Cannot implicitly convert type `UnityEngine.Rendering.TextureDimension' to `UnityEditor.ShaderUtil.ShaderPropertyTexDim'. An explicit conversion exists (are you missing a cast?)
    Thanks!
     
  2. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    I'm glad you figured it out.
    If something like this shows up again, another thing to keep in mind is that the mesh has to be in a layer that the Terrain Height Renderer can see.
     
    Deleted User likes this.
  3. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    It appears that Unity still hasn't approved my update to Surface Waves, for some reason. If you mail me your invoice number, I'll verify it and send the latest version to you manually. It includes several changes that makes it work way more smoothly in Unity 2017.

    The mail address should be visible in the asset store.
     
    Don-Gray likes this.
  4. PeteMichaud

    PeteMichaud

    Joined:
    Jul 11, 2015
    Posts:
    25
    I'm considering buying, but I'm a little worried. This form seems recent, but I look at the issue tracker and it was last updated in 2015, the only reviews from like 3 years ago say that the documentation is inadequate, with no response from you. I'm just wondering if this is in active development, will actually work with recent versions of unity, and will actually be performant to use in a real game?
     
  5. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    It is indeed an old asset. But I recently updated it to work with Unity 5 and up (runs fine in 2017). Unfortunately Unity hasn't processed my update yet, so I send the update manually to people when they send me their invoice number.

    So, no, it's not in active development. And whether it is performant or not in a real game depends on what you want to do with it. Running any kind of simulation on the GPU has the downside that it is a bit trickier to make the game react to the simulation (because sending data back to the CPU is 'slow', though still interactive), but the latest version now includes some code to make that easier for you. And I still try to respond to support e-mails as soon as I can.

    The issue tracker has not been update since 2015, but I was also the only person submitting issues there.

    If you buy the asset and find out that it is not for you, just send me an e-mail with a refund request, so that I can submit it to Unity. They generally grant any request I forward to them within a couple of days.

    But here's hoping that won't be necessary. It still works.
     
  6. PeteMichaud

    PeteMichaud

    Joined:
    Jul 11, 2015
    Posts:
    25
    Thanks for the reply. I'd basically be sold at this point if the full source is included -- that way if something does go wrong or if I need to add a feature or do performance tuning, I can actually do that, regardless of what happens in the next couple years with official development. Is that part of the package, or might you consider including it?
     
    RC-1290 likes this.
  7. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Oh yeah, definitely. It's basically just a bunch of scripts and shaders. That's what makes it a small download too ^_^.
     
  8. Deleted User

    Deleted User

    Guest

    I love the look and responsiveness I'm getting from this plugin!

    For game-play reasons, I'm looking for a way to zero out the height when sections become disconnected from a source, or to drain pools that are stagnant. Maybe something akin to lifetime in a particle fluid sim for areas of the surface that aren't having their height increased anymore. I tried a global drain, but anything high enough to even be noticeable just drains the whole surface too fast to be useful.

    One possible way is using blob detection to find disconnected pools and then instantiate a drain to zero them out as they are detected. Is there something obviously better available?
     
  9. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    I really like the idea of this asset a lot but unfortunately asking $80 for an asset that hasn't been updated in 3 1/2 years is quite pricey and risky. In addition, it looks fairly dated (not bad looking, though.) I really wish you would consider modernizing this (I'm guessing the real issue is it's probably very hard to make money on the asset store.)
     
  10. Deleted User

    Deleted User

    Guest

    Hey Steven, I assume you saw the earlier post from RC-1290? The asset was recently updated, but it hasn't been approved on the asset store yet. It would be nice if that got posted at some point, but in the meantime I can vouch for the update that RC-1290 sends, it is running just fine in my Unity 2017 project.
     
  11. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    Thanks for taking the time to reply and give some feedback on the latest version.

    I saw that there is a newer version but 3 1/2 years between updates is not a good track record for an $80 asset.
     
  12. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Or maybe it just works ;)

    Jokes aside, I'm gonna try re-submitting the update. I still haven't heard anything back from Unity and having everything go through e-mail is silly.
     
  13. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Hmmm, it sounds like you'd want to create a new type of drain that analyses the flow map. The flow map is an intermediate simulation texture, that contains all movement between cells in the simulation. When water becomes entirely still, it'll zero out (or close to it) on the flow map.

    The Wave Flow Step GameObject contains the code that currently deals with flow map data. It should help you when writing something custom.
     
    Deleted User likes this.
  14. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    Hi RC-1290,

    Last time I received the update you sent and it was running fine on Unity 5.6.0.
    Thank you so much.

    In the development process, I'm having a problem with "Rendered Layers", and look forward to your help.
    Below I posted a photo describing the problem.

    Currently, in Terrain Height Renderer GameOject, I'm setting Rendered Layers as "Default" value and setting the layer of the building as "Default". Then the waves showed up on the walls of the building. If I do not set the building's layer as Default, then the problem is solved, but the waves will not be affected when colliding with the building.
    Is there any way to set up waves that still collide with the building without being put on the wall?

    Thanks.

    キャプチャ.PNG
     
  15. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    This is tricky. It's essentially an aliasing problem; the water resolution isn't nearly high enough to match the building exactly at the wall, but all the vertices that make up the waves are still connected so you end up seeing a lot of the water mesh reaching to a place where the simulation knows there's no water.

    You could try to make sure that the walls of the buildings are exactly aligned with the grid of the simulation, but that's a pain to do, so I'm going to look into some alternative solutions, to see what I can come up with.
     
  16. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    I forgot about this, but apparently I already wrote something that can help to mitigate this artifact. On the Wave Mesh Offset Step there is a Low Wave Bias setting. When the water is below a certain level (0.5 by default), it tries to smooth it out the height of the mesh so that it's slightly below 'terrain level'. Setting that slightly higher should reduce the height of the apparent water level near those buildings. It can also help to use the 'complex' water shader, which fades out near the edges.


    Because the Low Wave Bias setting is a constant value that applies the same everywhere, it's a bit of a trade-off. If it's high enough to avoid the 'climbing' water effect, it can cause dips at the edge of the water on a smooth beach surface. It's a trade-off.

    You could programmatically change this Wave Mesh Offset Step to determine the appropriate water height based on the neighboring pixels, essentially performing anti-aliasing on the WaveMesh displacement texture, but that would come at the cost of several more texture look-ups, and / or the new artifacts of whatever anti-aliasing code you end up writing.

    It could be further smoothed out by adding some form of hardware tessellation support in the water shader, but that might end up being quite a project.
     
  17. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    Thanks for taking the time to reply and give me alternative solution.
    When I set the value of Low Wave Bias higher (10-30) can improve. ^^

    Also, when I create a new GameObject or use a Floating Cube Object, I get the error as shown below.
    Is there a way to solve this problem?

    Thanks!

    キャプチャ2.PNG
     
  18. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    To improve that situation, you'd need a different kind of water displacement that I never got round to implementing. Top down displacement. It's less straightforward than regular water offsets, so I'm not sure if I could implement that quickly. It has always been on my wishlist though...

    Incidentally, top down displacement might also improve the situation for other objects, like buildings and trees, so it's definitely interesting. I'll see if I can create a test this week, in case it turns out to be easier than expected.
     
    NeatWolf likes this.
  19. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    When colliding with water, the floating cube object automatically moves upward, possibly due to the force from the bottom.

    I am looking forward to your test results on this week.

    Thank you very much
    (bow)
     
  20. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Oh, you were just talking about stopping the cube from floating upward? That's happening because the cube is set as 'terrain', so the water level is consistently at the top of the cube. Move it to a layer that the Terrain Height Renderer does not see as terrain.
     
  21. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    I have read this in your guide. But I still want to set it up as a 'terrain' for the purpose that waves can impact on objects.
    However, then I encountered both problems above.
    My goal is to see the wave acting on the object and make it move depending on the magnitude of the wave.
     
  22. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    That's what you'd need the 'top down' displacement for, which I haven't written yet.

    What I did create was the anti-aliasing for wave meshes, so that you get smoother transitions between vertical objects and water without having to mess with any settings.

    Surface Wave mesh anti-aliasing.PNG
    It seems to work pretty well, as long as there's no water on top of the structure. Obviously overhang is still an issue, but that's simply because it's a 2D simulation.

    One step at a time. I'll include it in the next release.
     
    antoripa likes this.
  23. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    That right.
    Also, I want to simulate a tsunami. It will swing objects along its path. Waves will force the object and make it move.
    Same as in this video, starting from 0:18s
    .
    Can I simulate this based on Surface Wavs Asset?
     
  24. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    What you linked is a full 3D simulation, which you definitely can't do with Surface Waves. In a 2D simulation the water height can only go up and down, you can't have things like rolling waves.

    Have you tried out the experimental buoyancy built into Surface Waves? Objects should be dragged along with the flow of the water (though they won't realistically displace water).
     
  25. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    That said, I did get a top-down displacement prototype up and running. Currently it assumes that everything that's below the surface of the water, extends all the way to the top of the simulation. I could render the displacing objects another time, to figure out if water could flow over them, but that would still see multiple objects that are above each other, as one...
    top down displacement 1.PNG

    This probably won't combine well with buoyancy yet, because that uses the top of the water to apply force, so when an object pushes the top of the water down, it moves farther down. It would be cool if the actual pixels of the displacement determined the amount of force applied upwards, but... that would require rendering each of them separately, and then processing the images created, which in my head seems like quite a slow thing to do.
     
  26. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    Yes, I tried out the experimental buoyancy built into Surface Waves, but i can't handle speed of the buoyancy, control faster or slower.
    It seems to work pretty well.
    Can you send me this unitypackage directly?
    Thanks for taking the time to reply.
     
  27. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Update time.

    Occasionally I update the asset when customers approach me with specific issues they're having.
    As such, we're currently at version 14. Though it won't update through the Unity asset store, because the updates seem to disappear from the review process. I hope Unity support will get back to me about this at some point.

    In the meantime, if you need any of the changes listed below, please e-mail me with your invoice number, so I can send you the latest version. (in case you're wondering why only a few versions have changes associated with them, that's because of test-exports that needed further work)

    V_14 Changelog
    • Fixed errors caused by lack of topdown displacement code in the Vertex/Fragment version.
    V_13 Changelog
    • Smoother Wave Mesh Offset step - fixes the water apparently climbing up vertical walls, and smoothes out shorelines in general. Might be slightly more expensive (8 extra texture lookups D:)
    • Removed 2 * atten from old Unity lighting.
    • Top Down displacement
    V_11 changelog
    • Unity 5 / 2017 support
    • Support for reflection probes
    • Saving / Loading
    • Fog fix
    alpha 4 changelog
    • Framerate Independent Simulation.
    • Updated help descriptions.
    • New Demo Scene
    • Dropped Unity 4.3.4 support (more tooltips, Less buggy undo)


    I miss steampipe.
     
    Don-Gray and Fodalichking like this.
  28. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Good news. The issue has been found, and you should now have access to the latest version via the asset store again. The one downside is that Unity 4.5 is not supported at all anymore.
     
  29. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    This is very good news.
    Thanks for update :D
     
  30. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Wave Height Offset creator appears to be broken in Unity 2018.1.0b11 appears to be broken. Investigating now.
    [edit] solution found, update is out
     
    Last edited: Apr 3, 2018
  31. kyenonline

    kyenonline

    Joined:
    Jun 29, 2017
    Posts:
    1
    HI publisher,
    How can i calculate the force of surface wave acting on the wall
    I want to demo a big wave can break the wall

    Many Thanks
     
  32. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    That's a tricky one because of the split between Unity Physics and the physics involved in this simulation. And because the waves aren't 3D; Terrain normally only contributes a force through its height, and with terrain normally being the earth (i.e. a giant planet), it can be ignored.

    For erosion simulation forces are sometimes based on estimated water velocities. There is some shader code for that used for foam creation. That's an approach you could look into. Or you could compare the flow simulation texture with the coverage of your physics objects, and make assumptions about the contribution on flow, by that physics object.

    After that, you'd have to turn that pixel information into a set of forces to send back to the CPU for Unity's physics. You should be able to get a hint on how get data back to the CPU from the the 'simulation saving' code that now comes with the asset, or the older buoyancy code.


    tl;dr: You can't without some clever innovation.
     
    kyenonline likes this.
  33. HakiZ

    HakiZ

    Joined:
    Nov 6, 2015
    Posts:
    10
    Hi RC-1290,

    I'm working with surface waves asset and have a problem, hopefully get some help from you.

    I am creating a wave simulation area with parameters as below:
    Size: 1024x128x512
    Resolution: 1024x512
    Total Grid Unit Count U-V: 1024x512
    Segment Grid Unit Count U-V: 64x64
    Total Mesh Width: 1024
    Total Mesh Depth: 512

    However, I have a problem that the mesh of the wave is deviated from the mesh of the building.
    When I switched to the size of 1024x1024, the mesh position of the wave and the building matched,
    but with a resolution of 1024x1024, the performance (FPS) was reduced a lot.

    The question is can I create a wave simulation area of size 1024x512 that the mesh of the wave and the building match?

    Best Regards, D-Kid.
     

    Attached Files:

  34. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Do I understand correctly that you want a non-square simulation?
    I don't think I ever really made sure to make that work correctly. You could try removing some of the hard-coded enforcement of square simulations, but I can't guarantee it'll work well and perform well.
     
    kyenonline likes this.
  35. empirebattles

    empirebattles

    Joined:
    May 17, 2013
    Posts:
    19
    I like the premise of this system.
    A few questions: Can this be done dynamically in game?
    I'm working with a randomly generated map (which is generated via a heightmap), and am wanting to implement some water functionality, without it being just static water. With that in mind, is it possible to set this up to be fed info from a script about where to source water to, and let the rest play out? I'm still exploring options right now to see which systems will be better for these needs, but i REALLY like this system (even if not for this project :D)
     
  36. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    It uses a fairly standard Unity camera to render the scene to a heightmap, so if you run that step after your terrain generation or every frame, you can make the water react at run-time or in real-time. Water sources/drains are also fully dynamic GameObjects.

    Something worth considering:
    While I try to address crashes and errors if they pop up with new Unity releases, these days I earn my living with other work, and generally can't add any new features. That said: the asset includes all the source code, so any changes you need, you can write.
     
    empirebattles likes this.
  37. C_p_H

    C_p_H

    Joined:
    Nov 24, 2014
    Posts:
    153
    Hello @RC-1290

    What an outstanding Surface Waves water asset you've created. I discovered this forum by pure accident.

    Just FYI, both support & site links are down on the Unity Asset Store (gives a false impression that Surface Waves could be deprecated to any new potential buyers).

    Edit: Progress Updates Forum Thread works, but Support & Publisher site links are down.
     
    Last edited: Sep 9, 2018
  38. Lesnikus5

    Lesnikus5

    Joined:
    May 20, 2016
    Posts:
    131
    Hello!
    I am very interested in your asset. It is a pity that you no longer develop it. Unfortunately, the demo version in the web player is no longer available. $ 80 is too expensive to buy the asset blindly, without testing. Can you build a new demo? It would be great! If possible, make a standalone Windows demo, not a web player. It is more convenient for me.

    I also sent a letter to your email, but it seems that this adress does not exist anymore.

    In any case, thanks for such an interesting product.
     
    NeatWolf likes this.
  39. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Ooh, I should take a look at the support and site links. I wonder when those went down. And while I'm at it, I should update the demo, with a stand-alone option. I did see your e-mail Lesnikus5, but unfortunately I can only process those in weekends these days, which are very full lately.

    I'll make a note to look at these things next weekend, hopefully that ends up working out (I meant to do those things this weekend, but as you can see from this message, that wasn't an option :/ )
     
  40. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    Thanks for your patience! Turns out my webhost decided to stopped supporting aliasing for their own hosting packages. codeanimo.com should be back up and running.

    I've added a 64-bit Demo scene here.

    The smart marketing thing would be to update the webpage to link to this new demo. But right now I have to run to catch a train :).
     
    Lesnikus5 likes this.
  41. C_p_H

    C_p_H

    Joined:
    Nov 24, 2014
    Posts:
    153
    @RC-1290

    Can you also upload a 64-bit Demo for macOS Metal please, as soon as time permits.
     
  42. meichen8050753

    meichen8050753

    Joined:
    Jan 16, 2017
    Posts:
    37
    Hello @RC-1290

    There are anyway to simulation waves like this?
     
    Last edited: Feb 18, 2019
  43. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    You can do something like that by pointing a depth camera at the sand, and sampling its output to create a heightmap as input for the simulation. The tricky part is probably getting it exactly transformed and lined up correctly.

    I'm not entirely sure if the water simulation they're using is also a shallow water simulation, or something fancier, but you could certainly create something like this with a simulation like Surface Waves.
     
  44. meichen8050753

    meichen8050753

    Joined:
    Jan 16, 2017
    Posts:
    37
    @RC-1290 Thanks for your replay
    This is the project vodeo I developing.


    Thara some problem troubling me, Thara are any way to make waves more obvious (make water have more kinetic energy) as the Augmented Reality Sandbox. ps : I'f I set the wave source whith a higher Input Intensity, the water will full in little time
     
    Last edited: Feb 24, 2019
  45. JaydenCampaignEdge

    JaydenCampaignEdge

    Joined:
    Mar 28, 2018
    Posts:
    3
    Hey @RC-1290

    Love the plugin, working amazingly. Quick question, is there anyway to have textures mapped to the surface? I'm specifically trying to create Lava, something like this or roundabout:



    Just looking to drag and drop an image or texture in, do you know how/where i can edit the shader to allow this?

    Cheers.
     
  46. meichen8050753

    meichen8050753

    Joined:
    Jan 16, 2017
    Posts:
    37
    Yes you can, just rewrite the shader Code Animo/Surface Waves/Complex Water and ComplexWater.cginc
     
  47. JaydenCampaignEdge

    JaydenCampaignEdge

    Joined:
    Mar 28, 2018
    Posts:
    3
    I had a crack at it myself but with no results, any chance you could provide me with the code? That would amazing as i'm a little inept with shaders.
     
  48. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    meichen8050753 is right. The one thing that makes this slightly more complicated than usual is that the shader is split into two files. The short shader file that contains all the input properties, and lists the shader variations, and the long cginclude file, that contains most of the actual shader code.
    You'll need to add the texture property to the shader file, and the texture sampling code in the fragment shader code in the cginclude file.
     
  49. Lab58EswinParedes

    Lab58EswinParedes

    Joined:
    Aug 24, 2019
    Posts:
    2
    Just wondering if this package is still active and being supported. I believe I read above and it seemed that this asset's latest version has not been uploaded yet (due to difficulties) and you must be contacted with proof of purchase. Is this correct?
     
  50. unity_124535

    unity_124535

    Joined:
    Jun 2, 2019
    Posts:
    1
    why do you charge so much? It's kind of annoying :-(
    I will get it if it is at least a bit cheaper. I can bargain around 10 to 35 dollars. Aquas was 10 dollars and yours is like Aquas but water flows. Anyhow if you don't want to change the price, bump it down to 70 dollars and make it Gaia compatible. I got Gaia for a reduced price.