Search Unity

SUIMONO 2.0 - Interactive Water System

Discussion in 'Assets and Asset Store' started by chingwa, Jan 6, 2015.

  1. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @Efril By default buoyancy only starts calculating within a certain defined range. I believe you should be able to fix this by adjusting the buoyancy object settings... Try setting the 'Activation Range' on each of your objects to 0. This should disable the distance check and allow buoyancy to generate regardless of distance.

    If this doesn't work then you can adjust the code to ignore the distance check. Open the Scripts/fx_buoyancy.cs file and search for the following...
    Code (CSharp):
    1.                 //check for range activation
    2.                 if (activationRange > 0f){
    3.                     currRange = Vector3.Distance(moduleObject.setCamera.transform.position, physTarget.transform.position);
    4.                     if (currRange >= activationRange){
    5.                         performHeight = false;
    6.                     }
    7.                 }
    You can either comment out the entire block, or you can set the 'performHeight' to true, like this...
    Code (CSharp):
    1.                 //check for range activation
    2.                 if (activationRange > 0f){
    3.                     currRange = Vector3.Distance(moduleObject.setCamera.transform.position, physTarget.transform.position);
    4.                     if (currRange >= activationRange){
    5.                         performHeight = true;
    6.                     }
    7.                 }
    Let me know if this still doesn't work for you.
     
  2. Efril

    Efril

    Joined:
    Aug 31, 2013
    Posts:
    36
    I don't use fx_buoyancy as it seems it required to create a huge amount of buoyancy spheres for large ship to float smoothely. I used buoyancy script from Dynamic Water Physics asset which modified to be partially multithreaded. It depends on Suimono.SuimonoGetHeight method.
    Never mind, I will code my workaround said in previous message. It is not perfect but should work.
     
  3. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    I see. I have not tried the DynamicWaterPhysics myself, so am not sure why the buoyancy would cut-out at distance. I can tell you that the SuimonoGetHeight() function itself does not have any distance options, and it should return proper water/wave height regardless of distance, so perhaps there's a distance setting in the DynamicWaterPhysics code?
     
  4. Efril

    Efril

    Joined:
    Aug 31, 2013
    Posts:
    36
    I'm not 100% sure but I could not find any in Dynamic Water Physics even when digging into its code to give it a bit multithreading power.
    Suimono obviously can't calculate waves at infinite distance and I thought that 'Ocean Scale' parameter defines the distance at which nice detailed waves are rendered and appropriate wave heights calculated as well. I see that if second ship is out of this radius (if 'Ocean Scale' is low, border can be seen with 'binocular' in my game) then it 'jumps' when switching camera to it (wave heights calculation started only when camera is close to it). If second ship is within this radius - all looks great to me.
    I can probably record a video if you have time and intereseted.
     
  5. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    You're correct that the ocean scale defines the area where the detailed waves are rendered. However, the GetHeight function does not rely on the detailed mesh for it's calculation (it just calculates offset based on the wave texture data), and should be able to calculate at any point. Obviously the further away from the camera you get you may start to see precision errors that are common in large Unity scenes.
     
  6. Efril

    Efril

    Joined:
    Aug 31, 2013
    Posts:
    36
    @chingwa I don't know how but 'Ocean Scale' parameter definitely affects SuimonoGetHeight() method since that method is the only connection point between Suimono and Dynamic Water Physics. Please, check the video below for illustration:

    Also please note that I used custom texture in 'Tex Normal R' slot of Suimono module lib script as you advised to me earlier. Not sure if it can cause the problem.
     
  7. Efril

    Efril

    Joined:
    Aug 31, 2013
    Posts:
    36
    @chingwa , I keep playing with Suimono and no Dynamic Water Physics this time. I created really simple scene with Suimono water and 2 floating spheres (distance 1000) with buoyancyObject prefab instances as childs. Activation range of these buoyancyObjects set to 0. I also updated fx_buoyancy.cs so performHeight variable set to true instead of false as you adviced:
    Code (CSharp):
    1.  
    2. //check for range activation
    3. if (activationRange > 0f){
    4.       currRange = Vector3.Distance(moduleObject.setCamera.transform.position, physTarget.transform.position);
    5.       if (currRange >= activationRange){
    6.              performHeight = true;
    7.      }
    8. }
    9.  
    Now it is clearly seen that far sphere falls down when 'Ocean Scale' parameter is small and normally floats if it is large. I can upload this test project somewhere and give a link.
     
  8. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @Efril I'd be happy to look at your test project. You can send me the link directly at konnichiwa@tanukidigital.com
    I'm heading out for the night, but should be able to take a look and see what's going on this weekend.
     
  9. RealSoftGames

    RealSoftGames

    Joined:
    Jun 8, 2014
    Posts:
    218
    is there a way to play audio volume based on distance from a water body? closer you are the louder it is(Set to max volume) further away it scales down to eventually nothing. its playing audio even when on main land
     
  10. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @aquilinajake No, not currently. The best thing to do would be to disable the Abovewater sound in Suimono, and then distribute normal Unity AudioSource objects where you need them around your scene using the same sound clip.
     
  11. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    33
    hello and so much thanks for great asset i'm using suimono water system for may ocean simulation but i have an issue with it
    as i'm a artist not an good coder so i come up with buoyancy problems
    i have an aircraft carrier and i cant make it to be on the ocean surface i've tried using buoyancy script but that doesn't make any change
    any help will appreciated
     
  12. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @pourya011 Do you mean it keeps sinking below the surface? First I would set the buoyancy objects activation range to '0' which will prevent buoyancy turning off at distance. Then make sure you you have both rigidbody and collider on your aircraft carrier?
     
  13. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    33
    sorry for stupid questions but as i mentioned i'm a noobie in coding
    how much buoyancy objects i need for a big object?
    imagine the scale is @Efril ship's scale on the video
     
  14. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    For a ship like that I would start out with 4, one in each direction around the bow of the ship at the waterline. Then I would add more, dispersing evenly around the ship, until you get good wave stability. You'll also want to add a small amount of drag/angular drag to your rigidbody to prevent physics shaking issues.
     
  15. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    33
    @chingwa so much thanks for the fast response i'll do what you told and will update my answer
     
  16. Efril

    Efril

    Joined:
    Aug 31, 2013
    Posts:
    36
    Hello @chingwa. What is the best way to change direction of waves? Playing with 'Wave Direction' value seems to changes only the water flow directions and waves themselves keeps at 0-180 direction. I tried to rotate 'SUIMONO_Surface' object around Y axis but it immediately resets to zero rotation. I tried to rotate 'Suimono_Object' and 'Suimono_ObjectScale' and this actually rotates the waves but seems producing inaccurate wave height calculations.
     
  17. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @Efril Unfortunately this is not something that can be done in Suimono at the moment. To rotate the actual wave-forms you would need to rotate all RGBA channels in the wave texture, which isn't something that can be changed on the fly.

    For what it's worth I have done some work along these lines to be able to rotate the wave forms via a slider, but it is still experimental and I have yet to match buoyancy to rotated waves. This won't be coming to 2.x versions, but is possibly something that will be doable in 3.
     
  18. VavylonaEntertainment

    VavylonaEntertainment

    Joined:
    Oct 21, 2015
    Posts:
    142
    Hello, what are your plans with HDRP? Is it currently compatible?
     
  19. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @VavylonaEntertainment It is not currently compatible. I do not have plans to support LWP or HDRP in the short term, as these systems are still being developed by Unity and they are still fluctuating. I will support scriptable render pipelines in the future once Unity standardizes them... Perhaps that will be by the end of the year, or perhaps it will be further into 2019. It remains to be seen. Eventually these new pipelines will become the default in Unity, but I think that is still a ways off.
     
    Efril and VavylonaEntertainment like this.
  20. VavylonaEntertainment

    VavylonaEntertainment

    Joined:
    Oct 21, 2015
    Posts:
    142
    Can bigger waves be created? Im talking about BIG storms with waves larger than the ships. Also how does boyancy work with objects like ships that are not spherical or cubical but more like elongated boxes?
     
  21. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @VavylonaEntertainment Yes Suimono has the option to do large waves. You can customize the height and frequency of large ocean waves. For buoyancy on a ship it's best to add multiple buoyancy objects around the prow of the ship at the water line, and then tweak the buoyancy object settings for stability. There's a demo included showing how this setup can work on a basic boat.
     
    VavylonaEntertainment likes this.
  22. VavylonaEntertainment

    VavylonaEntertainment

    Joined:
    Oct 21, 2015
    Posts:
    142
    @chingwa nice, but what about the case where the ship is "climbing" the wave and then has to "fall/slide" on the other side? How does physics work there?
     
  23. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    That should work the same way. They Buoyancy objects only apply force when the object is underwater, so they'll get force applied when it's climbing the wave, and no force as it crests and falls down. The buoyancy objects should be parented to the boat, so they will follow in the correct position regardless of where the boat goes.
     
    VavylonaEntertainment likes this.
  24. JazZRocK

    JazZRocK

    Joined:
    Dec 17, 2015
    Posts:
    32
    Hello :)

    Your asset look great !

    Before purchase, i need to know:
    1.With your buoyancy system, i don't need to buy, for exemple, the "Realistic Water Physics" asset to simply simulate ship movement accordingly to the swell of your ocean... I'm right ? (I want to give the player the urge to throw up ! Joke).
    2.Your ocean is compatible with "Enviro Sky And Weather" asset ?

    Thanks you :)
     
    Last edited: Jul 6, 2018
  25. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    Hi @JazZRocK Thanks for your interest in Suimono!
    A buoyancy system is included in Suimono, so you do not need a third-party buoyancy system. Some people prefer using a more in-depth system though, depending on their needs. I have not personally tried Enviro, so I cannot comment 100% on compatibility. I can say just by virtue of how Suimono renders that it is more compatible with sky systems and image effects than most other water systems. I'm sure if any problems arise between the water and sky they can be addressed with a bit of back and forth between us.
     
  26. JazZRocK

    JazZRocK

    Joined:
    Dec 17, 2015
    Posts:
    32
    Thanks you very much for your fast reply !!
    I will buy it right now !

    Edit: I bought it, and...it work really well with Enviro !!!
    (Fan of your "Deep Dark Ocean" preset !!!)
     
    Last edited: Jul 6, 2018
    chingwa likes this.
  27. JazZRocK

    JazZRocK

    Joined:
    Dec 17, 2015
    Posts:
    32
    Do you have an option to hide small location of water based on a volume like the inside of a boat/submarine/etc ?

    Because i can't find it in the manual.

    Thanks you :)
     
  28. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    There is an example in the advanced demo where the small boat has a 'hide' shader over the opening. You can use this same shader/material in a similar way for other places you would need to hide areas of water.
     
  29. JazZRocK

    JazZRocK

    Joined:
    Dec 17, 2015
    Posts:
    32
    Thanks you :)
    However, under the depthmask quad, the unity post processing stack does not work anymore :s
    And the inside of the boat seems to have strange effect with a slight shift movement like the "Persistence of vision" , with depthmask applied :s
    Any idea ?
    And what is the difference between "DepthMask" and "DepthMask2" shaders ?

    Thanks you :) and sorry to bother you and for my bad english :s
     
    Last edited: Jul 8, 2018
  30. VavylonaEntertainment

    VavylonaEntertainment

    Joined:
    Oct 21, 2015
    Posts:
    142
    As much as i tried, i failed to make the waves large. They either go spikey or turn white from foam always without getting larger. Also, how do you make the plane larger? Just change the scale or is there a specific setting?
     
  31. JazZRocK

    JazZRocK

    Joined:
    Dec 17, 2015
    Posts:
    32
    Maybe in "Suimono_Surface" in "General Settings" with "Surface Types".
     
  32. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @VavylonaEntertainment I recommend going to the Surface under 'Wave Settings' and clicking on the 'use custom settings' option. From there you should be able to adjust the large wave height and large wave scale to give something more to your liking. With higher waves you will also probably then need to adjust the wave foam height/spread settings as well.

    If you're using the infinite ocean mode then it will fill your scene once you press play, regardless of the size you scale it in your scene. Otherwise you can just drag your Suimono_Surface prefab anywhere you like, and scale it using normal Unity scaling tools.

    @JazZRocK I believe you should be using DepthMask2 shader... the other is leftover from older Suimono versions (which I've kept so as not to break compatibility with old installs). I didn't realize there were problems with Post Process stack, can you tell me what version of Unity and PostProcess you're using?
     
  33. VavylonaEntertainment

    VavylonaEntertainment

    Joined:
    Oct 21, 2015
    Posts:
    142
    This is the best i could do:



    And the cube represents a character, which means there is still no big difference.
     
  34. JazZRocK

    JazZRocK

    Joined:
    Dec 17, 2015
    Posts:
    32
    I use "Unity 2017.3.1f1" and "Post Processing Stack 1.0.4"
    SuimonoWater_DepthMask_Problem.jpg
    I hope that the image can help.

    Thanks you Chingwa.
     
  35. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Is this fully compatible with Unity 2018.1.6 and Enviro - Sky and Weather system? I'm not planning on creating a VR game and only just for PC. Also, does this have built-in functions that I can easily call to transition between calm to turbulent water etc. while gradually also adapting the movements of objects (e.g. boats, buoys) on the water?
     
  36. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @RendCycle I've tested using Unity 2018.1 and Unity 2018.2 and all works as expected. You didn't ask about the SRP (hdrp / lwrp) modes in 2018, so just in case you should know that Suimono is not compatible with SRP, at least not until it comes out of preview and is more robust. You will need to use the normal Unity rendering when using Suimono with Unity 2018+. Buoyancy will react to whatever the current water settings are, and many water surface settings (such as wave height / color / etc) are accessible through code, so you can change them as needed.
     
  37. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @VavylonaEntertainment axing out the 'Large Wave Height' setting is the key to having large high waves. I never expected anyone would ever need higher than a 4.0, but the EDITOR/suimono_object_editor file can be adjusted if you need higher waves around line xx....

    from this:
    Code (CSharp):
    1. EditorGUI.LabelField(new Rect(rt.x+margin+10, rt.y+200, 120, 18),"Large Wave Height");
    2. script.lgWaveHeight = EditorGUI.Slider(new Rect(rt.x+margin+165, rt.y+200, setWidth, 18),"",script.lgWaveHeight,0.0f,4.0f);
    3.  
    to this:
    Code (CSharp):
    1. EditorGUI.LabelField(new Rect(rt.x+margin+10, rt.y+200, 120, 18),"Large Wave Height");
    2. script.lgWaveHeight = EditorGUI.Slider(new Rect(rt.x+margin+165, rt.y+200, setWidth, 18),"",script.lgWaveHeight,0.0f,10.0f);
    3.  
    (changing just the last number factor from 4.0 to 10.0)
     
    VavylonaEntertainment likes this.
  38. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    @JazZRocK Thanks for the image. I'm having a hard time recreating this issue here, but it may be due to a specific post-process setting. Ambient Occlusion for example may cause view discrepancies. Can you PM me a copy of your PostProcess profile? One thing you can try that might perhaps help is to copy the Post Processing Behavior component from your main camera, and past it as a new component on the SuimonoModule/cam_SuimonoTrans camera. This also has the potential to cause other unwanted rendering issues but it may be worth a try all the same.
     
  39. JazZRocK

    JazZRocK

    Joined:
    Dec 17, 2015
    Posts:
    32
    PM sent !
    Thanks you Chingwa :)

    (If a solution to my problem is found in PM, I will come back here to post it in case I'm not the only one affected).
     
  40. VavylonaEntertainment

    VavylonaEntertainment

    Joined:
    Oct 21, 2015
    Posts:
    142
    This is perfect, it did it!
     
  41. seanybaby2

    seanybaby2

    Joined:
    May 17, 2013
    Posts:
    104
    ETA on compatibility with VR? I'd love to use this on my VR project.
     
  42. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
  43. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    330
    The new version fixes the water surface flickering in deferred mode – thanks for that.

    However, I still get razor-sharp shorelines under Metal:

    Screen Shot 2018-07-27 at 15.07.30.png

    Any idea when this will be fixed? It's been a few years now. ;) Metal has progressed to the point where this should be possible. Mac OS X 10.13.6, Unity 2018.2.1.
     
  44. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    Unfortunately I don't have access to a mac to test directly. It looks like from your screenshot that the transparency setting is rendering at a some multiplication of the intended color. I'm not sure why that would be... I am on the verge of releasing a new update though (ver 2.1.6) I've made a few edits in the shader for other purposes and I'd be interested to know if there is any difference in metal... should be ready by early next week.
     
  45. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,064
    Hi @chingwa - how easy it is to raise the water level in code, whilst maintaining the underwater effects and buoyancy - can you provide me with an example please? - thank you!
     
  46. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    Hi @julianr All you should need is to update the y-position of the suimono_surface object. When raising this up or down all the buoyancy and underwater code should automatically update in the background. Along the same lines you should be able to reposition the water in ither directions and everything will update as well.
     
    julianr likes this.
  47. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,064
    As easy as that, thanks. :) I'll give it a go.
     
  48. wasam

    wasam

    Joined:
    Oct 13, 2012
    Posts:
    5
    I tried to use SUIMONO 2.0 with World Streamer.
    When using the "floating point error fix system" (World Streamer) which resets the players position every now and then to world origin, SUIMONO 2.0 would correctly also displace the waves by the offset the player position just jumped.
    However, in this case the wanted behaviour is to pretend that the players position has not changed.
    This can be achieved by changing the following lines inside SuimonoObject.cs:

    (starting at line ~970)

    Code (CSharp):
    1.  
    2. float deltaX = Mathf.Abs(suimonoObject.transform.position.x - newPos.x);
    3. if (deltaX > spacer){
    4.     if (deltaX < 2 * spacer)
    5.     {
    6.         if (suimonoObject.transform.position.x > newPos.x) setScaleX -= offamt;
    7.         if (suimonoObject.transform.position.x < newPos.x) setScaleX += offamt;
    8.     }
    9.     suimonoObject.transform.position = new Vector3(newPos.x,suimonoObject.transform.position.y, suimonoObject.transform.position.z);
    10.     scaleObject.transform.position = new Vector3(newPos.x, scaleObject.transform.position.y, scaleObject.transform.position.z);
    11. }
    12. float deltaZ = Mathf.Abs(suimonoObject.transform.position.z - newPos.z);
    13. if (deltaZ > spacer){
    14.     if (deltaZ < 2 * spacer)
    15.     {
    16.         if (suimonoObject.transform.position.z > newPos.z) setScaleZ -= offamt;
    17.         if (suimonoObject.transform.position.z < newPos.z) setScaleZ += offamt;
    18.     }
    19.     suimonoObject.transform.position = new Vector3(suimonoObject.transform.position.x, suimonoObject.transform.position.y, newPos.z);
    20.     scaleObject.transform.position = new Vector3(scaleObject.transform.position.x, scaleObject.transform.position.y, newPos.z);
    21. }
    22.  
    All I changed, is to ignore the offset for the shader if a change is larger than 2 times "spacer".
     
    judah4 and chingwa like this.
  49. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,155
    Hi @wasam Good invstigation and that's a pretty elegant solution. I'll consider adding it into the official code release.
     
    wasam likes this.
  50. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    319
    Hmm, can`t see the + and - signs here in the preset manager. Using Unity 2018.2.2f1 free Version.