Search Unity

Ceto (Scrawks Ocean)

Discussion in 'Assets and Asset Store' started by scrawk, May 4, 2015.

  1. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    82
    @scrawk I know this is ridiculous, but I'm going to be building a pond and will need ripples on the surface when stones are thrown in. How hard do you think it would be to get Ceto to ripple realistically? There are other solutions that may work better of course, but I thought it couldn't hurt to ask. (Those solutions lack waves as pretty as Ceto has.)
     
    ibyte likes this.
  2. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    It would be overkill but if the pond is near the same level as ocean you might be able to do it.

    There is a normal slot on the wave overlay script that can modify the normals. You might be able to use that for the ripples. I dont know if you will be able to get enough detail in though.

    You can use the normal mask slot to turn down the default wave normals if they are to strong for a pond.

    I havnt tested the normals on the overlays much so not sure how practical it is. Their is only a setting to scale the uv's on the texture and I think you would need a offset setting as well to scroll through the sprites in the texture to animate it.
     
  3. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    ZOMG how did I miss this.

    When the budget comes... shut up and take my money.
     
  4. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    With the waveoverlay I have the cannonball splashes working correctly but when I was doing larger broadsides I noticed that the effect of the height change was cumulative and stacks the effect. So if two cannonballs hit near the same spot and their masks overlay each other then that part is twice the height. Am I missing something to make sure that the effect can be normalized for the overlay?
     
  5. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Yep, that's correct. The blend mode is additive so they will add up like that.

    I can try and look into a alternative blend mode that does what you want for a future update but Im not sure if its possible at the moment. Normal alpha blend is a bit complicated for the overlays.
     
  6. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hi, Perhaps this has been answered before but is there an option to convert the areas that appear as black voids into something else? (Nvidia 980 FTW card, Win 10 64)

    Capture.JPG

    Like - say - a splash particle effect.. (or will this be part of the foam finessing)


    if it is /easily/ possible to identify areas where this is occuring relative to the camera angle perhaps some particle effect spray could be added I was thinking/hoping.

    Is it easy to identify these crests as a rough group? to help in the adding of billows?

    I recognise this may fall in the camp of the "wind spray" I just read about but I am simply checking this is indeed the case. Many respectful thanks.


    EDIT: Oh Wait.. I finally got to page 3: http://forum.unity3d.com/threads/ceto-scrawks-ocean.323545/page-3#post-2150581 (your post) - I'll shut up now.
     
    Last edited: Nov 14, 2015
  7. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hi.

    Yes. Foam will get a bit of a overhaul soon and hopefully it will look like those images!
     
  8. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Code (csharp):
    1.  
    2. #if !UNITY_WEBPLAYER
    3. System.IO.File.WriteAllBytes(filename, bytes);
    4. #endif
    5.  
    (or similar)

    upload_2015-11-14_3-49-56.png

    for WebPlayer builds please ;)
    Cheers
     
  9. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804

    Oops, forgot about that. Thanks.
     
    twobob likes this.
  10. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Sometimes my blur break on reflections and I get this.
    upload_2015-11-14_5-51-19.png
    Which is actually very pretty.
    I'll check out the next ver when it drops cheers. Thought should report. Dx11 Deffered Linear.

    (Inside the tubes is awesome btw )

    Thanks so much for this
    AllTheWay.JPG
    Capture.JPG
    Capture2.JPG
    Capture3.JPG
    TotallyTubular!
    (You know, come to think of it an optional rainbow might be nice... hehehe):rolleyes:
     
    Last edited: Nov 14, 2015
    John-G likes this.
  11. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    By abusing the right settings Ceto also does a nice line in instant Ice Terrains :)
    0 wave speed, super high winds.

    Fun. Fun. Fun. Even the 'bugs' look nice when correctly maltreated :D
    Free alien structures

    InstantIceTerrains.JPG
    Heartily recommend.
     
    AdamGoodrich and BackwoodsGaming like this.
  12. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I think that one has been reported and fixed in next version although I don't remember it being so colourful.

    If this is the bug I think it is when using linear defered then enabling HDR on camera should fix it?
     
    twobob likes this.
  13. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Thanks, that totally got it.

    Tubes now Rainbow free.

    What's that coming over the hill?
    MonsterComingOverTheHill.JPG
    Is it a monster?
    YesItIsAMonster.JPG
    It is a monster...
    Tubular.JPG
    The Perfect Tube...
    Impact.JPG
    Boom!
     
    Last edited: Nov 14, 2015
  14. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Would it be possible to add a flowmap as an overlay texture that 'perturbed' the vertices of the surface so they followed the direction of the flowmap? Perhaps an amount controllable so the vertex position would waver between its original position and the direction indicated by the flowmap (im talking a typical valve style map, but changing the apparent direction not just with normals but with geometry too? Basically - rivers. In addition to this would it be possible to have the water mesh be of any shape? And possibly 2 ocean objects in the scene, although the river could come about through raising its height as it goes inland with an overlay map?

    These were some ideas i had since the overlay feature seems possibly very powerful
     
    twobob likes this.
  15. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Not sure about the flow map stuff. That might be a bit of a stretch. The rest of the ideas seam doable.

    Maybe support for multiple ocean could be added in future. Guess you could have one for the main ocean and another for a large lake, etc.

    You can use a overlay to adjust the height for a river but there is a limit. Maybe +/- 30m at most.

    I will be looking into river/lake support at some point.
     
    hopeful likes this.
  16. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    upload_2015-11-15_16-11-44.png
    Is the demo to unity 1:1 scale?
    When I dropped in a few other resources the stuff seemed really big.

    I rammed a 1m2 cube in the boat (to sanity test...) and it seemed like that concurred.

    upload_2015-11-15_16-14-45.png

    Just thought I would throw it out there. Maybe the non-obvious scale on the other boat is just confuzzling me
     
    Last edited: Nov 15, 2015
  17. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The boat in the demo scene is quite large. Not sure if its to scale. Its certainly a lot bigger that your wood boat.

    Theres a grid scale on the wave spectrum you can use to scale down the waves if needed.
     
    twobob likes this.
  18. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    No worries. I did a "1:1 Scale" , 1080p (Super Low Resource) webplayer build.
    For the purposes of some "Current State Of Play Minimum Specification @ 60fps" testing.
    I'll chuck it on a few machines and see how they fare.

    http://kaycare.co.uk/games/ocean/ (night scene, demo reel, no controls)
    upload_2015-11-16_5-46-20.png
    Very happy so far, thanks for your work.
     
    scrawk likes this.
  19. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Just a update to let people know that a someone has conformed that Ceto will run on a high end mobile device like the Samsung S6 or iPhone 6S. Thanks Gregory!

    Heres a pretty picture.

    CetoSunset.jpg
     
    Luckymouse, sashahush, John-G and 2 others like this.
  20. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    44
    What's in the latest update that entered service today ? :)
     
    John-G and twobob like this.
  21. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The latest Ceto version 1.0.8 is now on the asset store.

    Again this is just a bunch of bug fixes. Hopefully this will be the last of the bugs and I can start work on adding new features.

    There is now two ocean prefabs instead of one. Theres one set up for the transparent materials and one for the opaque. Hopefully this will make it easier for people to switch between the two if needed.

    Ceto Version 1.0.8

    - Fixed the issue where the sky intensity in the reflections was brighter than other objects.
    You will need to change the reflection intensity from 0.5 to 1.0 as it was lowered to 0.5 to try
    and offset the sky brightness.

    - Fixed a issue where reflection blur in deferred/linear was not working if camera did not have hdr enabled.

    - Fixed a issue where if the opaque materials used with deferred the underwater effect was not working correctly.

    - Fixed a issue where skybox was still in reflections if camera clear flags set to solid.

    - Fixed a issue where normals on underside mesh not reflected causing the underside to look to dark
    and have blue artefacts. This was most obvious when the underside was viewed against the terrain.

    - Fixed a issue where transparent shader not blending if noforwardadd removed from shader.

    - Transparent shaders now have a edge blend feature. This can be adjusted on the materials.

    - There is now a Ocean_TransparentQueue and a Ocean_OpaqueQueue prefab.

    - There will now be a warning printed out of the opaque materials are used without changing the
    underwater mode to USE_OCEAN_DEPTHS_PASS.

    - MAX_OVERLAY_HEIGHT increased to 30. The overlay manager will now check what the max overlay height alpha
    is and use that for the max displacement range. This will give a more optimal projection.

    - Fixed a issue where setting the useMipmaps param on a temporary render texture is no longer
    supported in Unity 5.2+
     
    elbows likes this.
  22. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    While performing testing for mobile I think I broke something for the Mac :)

    Tiled GPU perf. warning: RenderTexture color surface (352x263) was not cleared/discarded, doing <run with profiler for info>
    UnityEngine.GL:End()
    Ceto_OverlayManager:Blit(Vector4[], Vector2, RenderTexture, Material, Int32) (at Assets/Ceto/Scripts/Ocean/Overlays/OverlayManager.cs:558)
    Ceto_OverlayManager:RenderHeightOverlays(IEnumerable`1, RenderTexture) (at Assets/Ceto/Scripts/Ocean/Overlays/OverlayManager.cs:466)
    Ceto_OverlayManager:RenderWaveOverlays(Camera, WaveOverlayData) (at Assets/Ceto/Scripts/Ocean/Overlays/OverlayManager.cs:440)
    Ceto_Ocean:RenderWaveOverlays(GameObject) (at Assets/Ceto/Scripts/Ocean/Ocean.cs:927)
    Ceto.Common.Unity.Utility.NotifyOnEvent:OnEvent() (at Assets/Ceto/Scripts/Common/Unity/NotifyOnEvent.cs:70)
    Ceto.Common.Unity.Utility.NotifyOnWillRender:OnWillRenderObject() (at Assets/Ceto/Scripts/Common/Unity/NotifyOnWillRender.cs:22)
     

    Attached Files:

  23. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The other day I got a email from Morild Interaktiv with some screen shots of Ceto in a project they are working on.

    They are creating a offshore shipping training simulation using VR and being produced for Rolls Royce Marine.

    I recommend having a look at there website. These guys have some serious hardware!

    Screenshot_01.jpg
    Screenshot_02.jpg

    Screenshot_04.jpg

    Screenshot_05.jpg
     
  24. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Thats a new one. Can you let me know the steps to reproduce this?

    Looks like a issue with the overlays.
     
  25. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    Okay, I found the issue. So in the editor it is switching over to the rendering path for mobile when you switch platforms for mobile which is cool - but it can't/won't render that in the editor. When I switched back to the PC platform it apparently reimported stuff that had gotten removed and that stuff works now.
     
  26. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    I did notice that in order to get buoyancy working I had to make sure "Disable Read Back" was unchecked. Not sure why that is checked by default.

    One question I have is how I would properly compute the roll of the waves on the surface of an object in the water. For example in the demo scene there is no lateral motion of the ship when you crank up the wind and get big waves (hoping to get massive ocean waves proved fruitless). I'm guessing you just didn't simulate anything like that, but some of those waves should roll the ship.
     
  27. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    If the Fourier size on the spectrum is set to GPU then the data needs to be read back from the GPU which takes time and is dx11 only. It's disabled by default as it takes a massive perfamance hit to the fps.

    The big waves should roll the ship but the current buoyancy system is not very good and needs to be redone at some point. This would be done by calculating the torque on the ridged body.
     
  28. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    Okay cool. Not something I need at the moment, but cool that you're already thinking about it. As far the DX11 part, that's harder for me to correlate to my current situation as everything is OpenGL based (Android, iOS, OSX)
     
  29. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Theres nothing I can do about the dx11 part. Its not practical to read back floating point data from a render texture with out compute shaders. The GPU options were only added for high end dx11 applications or games where the ocean is just a back drop and dont need buoyancy.

    You will have to use one of the CPU fourier sizes which does everything on the CPU using multi threading so theres no read back required.

    For application where buoyancy is important its recommended you use the MEDIUM_64_CPU fourier size which is whats used by default. It runs very fast and still looks ok.
     
  30. jdvar

    jdvar

    Joined:
    Sep 27, 2013
    Posts:
    12
    Hi, how can I remove jittery wave effect? I've tried making my camera follow player by lerp instead of making the camera a child object to the player. But this doesn't help :( Btw, my game is first person. Please, help me. Thanks.
     
  31. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    Sounds like you need a more advanced camera... try this

    http://www.regress.com/kam3ra/
     
  32. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Is this happening when you have Cetos buoyancy script attached to your player and they are floating on the water?

    Or is its happening with out using any buoyancy and just when moving around the scene normally?
     
  33. jdvar

    jdvar

    Joined:
    Sep 27, 2013
    Posts:
    12
    In my scene I have a boat that has Ceto's buoyancy structure (with 4 child empty objects with buoyancy) attached to it. My character is standing on this boat and I'm getting this effect. I have no buoyancy attached to the character.
     
  34. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Its the buoyancy script that causes the boat to jitter and since your player is on the boat it jitters as well.

    The buoyancy scripts in Ceto will be re-written at some point and hopefully this will be fixed. Basically the ships movement needs to be smoothed out somehow.
     
  35. Tony-Lovell

    Tony-Lovell

    Joined:
    Jul 14, 2014
    Posts:
    127
    I have the asset and love its effect on my sim, but I find that I can, from a vantage points 250 units (meters) abeam a ship in high seas at 5 units above sea level, easily still see the submerged portion of its hull, even when a large rolling wave bodily enters the space between me and the ship.

    How can I adjust this to be much more opaque?

    edit: I found the issue goes away if I disable the Under Water script. I might want to pull that into use later, however.

    tone
     
    Last edited: Nov 17, 2015
  36. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hi, we have experienced Jitter in 2 circumstances

    a) Settings too high / Hardware too Low
    (This actually resulted in a "frame skip" style undulation rather than camera jitter)

    b) Buoyancy script attached to demo camera.

    We gave the \Assets\Ceto\Scripts\Ocean\Buoyancy StickToSurface script a quick read and it is this that has been extrapolated out via physics - in essence - line 99 of the bouyancy.cs "WaterHeight = Ocean.Instance.QueryWaves(pos.x, pos.z);" sums up what is happening plus a bit of swanky immersion calculation.

    Maybe (since this is a highly likely recidive topic) a quick and dirty test

    It's not a long script. As an example... http://kaycare.co.uk/games/ocean/ is a 32 Cpu build with minimum settings in every available area. (To satisfy the earlier testing considerations)
    The camera is rewritten to surf along an offset StickToSurface values path with a smoothed Slerped view back the ship. This does actually cause a tiny bit of jitter but very little compared to the current demo. The camera pans in and out automatically to facilitate seeing the effect at various distances, closer is usually less visibly stable.

    So long story short @jdvar rewrite your camera and also consider lerping the position rather than set it directly on an object when sampling heights.

    Cheers.
     
  37. AVerhoeven

    AVerhoeven

    Joined:
    Dec 30, 2013
    Posts:
    4
    Thanks a lot for this fantastic asset. It made my project look and feel great and it is by far the best ocean solution around. And I bought and tried a lot.

    A couple of questions if you do not mind:

    1) Would / could you consider adding a caustic effect, only thing missing to make the ocean floor look even greater?

    2) Would you be able to set up a couple of other prefabs, like lake, river, static water (pool / fountain)? Your water is by far the best and I would love to use it for any water I need in my projects.

    3) Will you introduce features like shore line (blending) and water splashing in?

    Anyway just some wishes, your product is already great and thanks for constant further developments.
     
  38. DivergenceOnline

    DivergenceOnline

    Joined:
    Apr 19, 2015
    Posts:
    244
    This version broke things even worse dude. The transparent prefab you can only see in the distance and only on the edge occasionally, and the opaque prefab results in everything below the waterline being even darker than it was before.
    (update: For whatever reason, switching from game to edit and back to game fixes the transparent surface not showing issue, but this obviously isn't a solution in a built client)

    -And the skybox isn't showing in the reflection.
    -And the edge blend is nice, but if you have to choose between edge blend and ToD scatter (transparent/opaque) this is something that needs to be stated as a notice on the asset store page.
     
    Last edited: Nov 18, 2015
  39. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    @scrawk upon further analysis we are fairly sure that
    WaterHeight = Ocean.Instance.QueryWaves(pos.x, pos.z);
    is errantly returning the height value without "Choppiness" added in.

    On our long running "Circle the Island" test we added a catmull-rom spline for smoothing and laterally noted the QueryWaves() values exacty matched the output of a wave with 0 choppiness, however higher chopiness values resulted in sub-aquatic height values from the method.

    Please could you confirm at some point that we are wrong. Many thanks.

    We updated the simple demo to reflect the problem simply.
    upload_2015-11-18_0-31-48.png
    Choppiness more = greater inaccuracy.
    Choppiness 0 = Spot on 99% of the time

    EDIT: We further updated the demo to illustrate some smooth sailing without jitter from a close camera angle, simply using your StickToSurface stuff.

    This build - Now stripped down to its bare bones - runs out at about 60FPS better on our hardware (just stripping out towers, all buoyancy etc.) You can go FULLSCREEN to get a non-vsynced result out of it. we get 180fps on our best box.

    upload_2015-11-18_3-13-59.png
    http://kaycare.co.uk/games/ocean/
     
    Last edited: Nov 18, 2015
  40. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hi Tony,

    If you adjust the above inscatter modifier on the underwater component it should make the ocean more opaque.

    If you open the above inscatter modifier settings you can increase the scale to make the ocean appear less transparent.

    You may need to change the mode from EXP2 to EXP.
     
  41. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hi AVerhoeven,

    Thanks :)

    1 - Yes, will be in a future update.

    2 - I will be looking into rivers/lakes at some point but that is a long term thing. Could be a while before I do it.

    3 - The new update has edge fade feature for the transparent materials if thats what you mean. Splashes will be in a future update.
     
  42. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Sorry about that.

    I can reproduce the issue with the transparent prefab so should have that fixed soon. Its related to what is set as the sky box. Can you let me know what you are using for the skybox material in the lighting settings for Unity please. EDIT - found the issue see last post for fix.

    With the underwater being dark for you I think the issue is with the depth blend on the underwater script. Can you set this to 0. Looks like there is a issue with it when not at 0.

    With the sky box in reflections can you go to the reflection script on ocean and make sure skybox in reflections is ticked, set the blur mode to off and set the reflection mask to everything.

    That last one is important I think the ToD is not selected in the reflection mask which is the cause of the problem. In the last version it was everything by default but I have changed that in this version.

    After doing this if there is still no skybox in the reflections can you post a screen shot of the issue please.
     
    Last edited: Nov 18, 2015
  43. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Yes, with choppyness on the wave query are not 100% accurate.

    The choppyness increases the amout of displacement on the xz axis which makes sampling the height at a location complicated.

    I presumed the error was small enough that it would not be to much of a problem. Maybe this needs to be improved a bit.
     
  44. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @DivergenceOnline and everyone: There is currently a bug with the transparent prefab if the skybox material in Unitys lighting settings is set to none.

    The transparent shader uses a command buffer to grab the screen and depth info for the underwater effect and I have set the event to run after the skybox.

    But If the skybox material is set to none then no AfterSkyBox event gets raise, the screen and color does not get grabbed and the transparent shader does not work.

    To fix this either set a skybox material (make sure camera clear flag is also skybox) or go to the Ceto/Scripts/Underwater/RefractionCommand.cs script and on line 41 you will see the event set...

    Event = CameraEvent.AfterSkybox;

    Change it to this fixes the issue...

    Event = CameraEvent.AfterForwardOpaque;

    Even though it says forward it still works in deferred.
     
    Last edited: Nov 18, 2015
    twobob and veddycent like this.
  45. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Although as time goes on we are being treated to compute shaders in Unity for additional, non-DX11 platforms. Off the top of my head this isn't too amazing yet because it only applies to certain versions on Linux & Android, and more development is required to support Apple platforms (since Apple have gone for Metal rather than a modern version of OpenGL which would be easier for Unity to use). But the future is brighter for this kind of thing, not that support on some mobile platforms necessarily makes sense in terms of performance.
     
  46. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Ah cool. :) We optimised the minimum build slightly (few redundant scripts/objects stripped et cetera) and ran our "Known Minimum Build" test on the slowest machine here (OnBoard Chipset Graphics) and managed to get 31FPS FullScreen (got 190FPS out of our best machine) via the webplayer. That is practically game-usable on the worst box. Will see if we can strip it down further.

    Many thanks for the consideration on the height testing, we figure
    circa tolerance +- 3m @ 0.5 choppiness currently at all times.
    circa tolerance +- 1m @ 0.0 choppiness currently, but perfect 99% of the time, there may be a floating round error somewhere? very occasionally.

    Incidentally, there is a 15% performance hit when setting Choppiness to 0.5 v 0.0 (25FPS v. 31FPS) on the lowest end machines, this may be a caveat to consider for optimisation on low end platforms. (Settings all at minimum Res, 32 CPU build)

    Further interesting info:
    Best Wind Speed for Visibly High Waves (sea level) ~ 75 MPH.
    Higher is not always more, whilst the offset may be greater it is hard to see at Sea level.

    Maximum Total Vertical Offsets
    = +75 / -65 = 140m total posible vertical displacement
    Wind speeds of up to 500 tried.
    upload_2015-11-18_19-14-5.png


    We also added a simple script to shift audio pitch values based on sampled heights (and magnitude) that we attached to the motor boat noise on our "Known Minimum Build" test.

    Happy to share this very simple script here.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ChangePitchBasedOnSampledValueOverTime : MonoBehaviour {
    5.  
    6.     [Range(0.2f,5.0f)]
    7.     public float HighestPitch = 3.0f;
    8.  
    9.     [Range(0.2f, 5.0f)]
    10.     public float MiddlePitch = 1.0f;
    11.  
    12.     [Range(0.2f, 5.0f)]
    13.     public float LowestPitch = 0.5f;
    14.  
    15.     [Range(0.1f, 5.0f)]
    16.     public float PitchSpeedChange = 1.0f;
    17.  
    18.     [Range(0.1f, 5.0f)]
    19.     public float MinumumMagnitudeToTaxEngine = 1.0f;
    20.  
    21.     private float previousTestHeight;
    22.  
    23.    // private float DeepestDepth;
    24.  
    25.   //  private float HighestHeight;
    26.  
    27.     private bool LerpInProgress = false;
    28.  
    29.     // Set this in the Inspector
    30.     public AudioSource audioSource;
    31.  
    32.     // Things height to track.
    33.     public Transform sampleHeightTransform;
    34.  
    35.     // Use this for initialization
    36.     void Start () {
    37.  
    38.         InvokeRepeating("SampleHeight", 0f, 1f);  // Feel free to increase the granularity.
    39.         //audioSource.pitch = 1.0f;
    40.         previousTestHeight = sampleHeightTransform.position.y;
    41.  
    42.     }
    43.  
    44.  
    45.     void SampleHeight() {
    46.  
    47.         float CurrentHeight = sampleHeightTransform.position.y;
    48.  
    49.         // KISS
    50.         float BiggestNumber = Mathf.Max(CurrentHeight, previousTestHeight);
    51.         float LittlestNumber = Mathf.Min(CurrentHeight, previousTestHeight);
    52.  
    53.         float magnitude = BiggestNumber - LittlestNumber;
    54.  
    55.         // Adjust the pitch back toward the "MiddlePitch" value if we are inside our allowed value change range
    56.         if (magnitude < MinumumMagnitudeToTaxEngine)
    57.         {
    58.             ConditionallyHaltCoRoutines();
    59.             StartCoroutine(LerpNumber(audioSource.pitch, MiddlePitch, PitchSpeedChange));
    60.             LerpInProgress = true;
    61.         }
    62.         // Adjust the pitch away towards the "LowestPitch" value since we are travelling downwards.
    63.         else if (CurrentHeight < previousTestHeight)
    64.         {
    65.             ConditionallyHaltCoRoutines();
    66.             StartCoroutine(LerpNumber(audioSource.pitch, LowestPitch, PitchSpeedChange));
    67.             LerpInProgress = true;
    68.  
    69.         }
    70.         // Adjust the pitch away towards the "HighestPitch" value since we are exerting greater stress on the engine.
    71.         else if (CurrentHeight > previousTestHeight)
    72.         {
    73.             ConditionallyHaltCoRoutines();
    74.             StartCoroutine(LerpNumber(audioSource.pitch, HighestPitch, PitchSpeedChange));
    75.             LerpInProgress = true;
    76.  
    77.         }
    78.  
    79.         // Optionally Log some potentially useful values.
    80.         //if (CurrentHeight < DeepestDepth)  DeepestDepth = CurrentHeight;
    81.  
    82.         //if (CurrentHeight > HighestHeight)  HighestHeight = CurrentHeight;
    83.  
    84.         //Debug...
    85.         //  print("HI:"+HighestHeight+" LOW:"+DeepestDepth+" CUR:"+ CurrentHeight+ " PRE:"+ previousTestHeight+" MAG:" +magnitude);
    86.  
    87.         previousTestHeight = CurrentHeight;
    88.    
    89.     }
    90.  
    91.     private void ConditionallyHaltCoRoutines()
    92.     {
    93.         // Meh, you can take out the ALL. I like to be sure.
    94.         if (LerpInProgress)
    95.         {
    96.             StopCoroutine("LerpNumber");
    97.             StopAllCoroutines();
    98.  
    99.             LerpInProgress = false;
    100.         }
    101.     }
    102.  
    103.     // Thanks EricLippert
    104.     IEnumerator LerpNumber(float start  , float end, float time)
    105.     {
    106.         var t = 0.0f;
    107.         var rate = 1.0f / time;
    108.         while (t < 1.0)
    109.         {
    110.             t += Time.deltaTime * rate;
    111.  
    112.             audioSource.pitch = Mathf.Lerp(start, end, t);
    113.  
    114.             yield return null;
    115.         }
    116.         LerpInProgress = false;
    117.     }
    118.  
    119. }
    120.  
    upload_2015-11-18_20-49-3.png

    It's pretty basic but gives the right impression when you use a nice whiney motor loop.
     
    Last edited: Nov 19, 2015
    John-G likes this.
  47. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    We gave the latest SkyMaster Beta a quick test.

    upload_2015-11-19_18-40-57.png

    It seemed to work nicely for our needs.
    upload_2015-11-19_18-41-42.png

    :)
     
    scrawk and John-G like this.
  48. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    514
    Is there any transparency fade in at the shore lines for ceto? This would make it much more realistic
     
  49. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah there is, but you currently have to make the shoreline mask texture yourself. As far as I know scrawk wants to add a tool for automatically generating them. I'd imagine it's just a quick depth render from above mutilated a bit.
     
  50. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    There has been a feature added for the latest version (1.0.8) that has transparency fade near the shores so the edges where the ocean meets the land are not so sharp, if thats what your referring to.

    This will obviously only work for the transparent materials not the opaque ones. The materials are set on the projected grid. The transparent ones are used by default. There is a edge fade setting on the material.

    I think Hippocoder was referring to the shore line masking which is a different feature. Its used to fade the wave height close to the shore.