Search Unity

Ceto (Scrawks Ocean)

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

  1. Drnkhobo

    Drnkhobo

    Joined:
    Jan 19, 2013
    Posts:
    5
    Hey Scrawk, firstly thanks for the cool asset! I see you have put a lot of work int it already :D

    Im busy trying to play around with your wave overlays and I want to know if there is any way to access the actual ocean surface mesh? If indeed you can at all? I would love to be able to do so!

    Keep up the good work!
     
  2. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Thanks

    The mesh data is in the projected grid script but the actual vert world position is not caculated. It's only in the shader that the final vert position is known.

    So basically no you can't access the mesh to modify it sorry.
     
  3. Drnkhobo

    Drnkhobo

    Joined:
    Jan 19, 2013
    Posts:
    5
    Thanks Scrawk, is there a way to access a copy of the vert positions? I want to add some wave buoyancy dynamics to your ocean and try get the waves to push objects... my idea after reading your post would be to then simulate this using the wave height query function to generate a history of heights and then calculate forces from that.

    Also on a side note, the wave overlays, do they have accurate wave height queries? Your demo shows the boat floating up/down when the example overlays are run through but my own project they dont seem to do the same. Any ideas?
    ;)
     
  4. JJJohan1

    JJJohan1

    Joined:
    Oct 13, 2013
    Posts:
    11
    Managed to get this running in WebGL quite quickly, basically just disabling multi-threading and ensuring the UnderWater class' RenderTextures are using a supported format. The underwater post effect isn't quite as lucky though.

     
    John-G likes this.
  5. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    To do this use the wave queries. Don't try and use the mesh verts. They don't contain any of the data you will need.

    You can get the amount of displacement applied to the vertex from the wave query and from that you can work out a velocity vector you can then use to push objects.

    Code (CSharp):
    1.  
    2.             WaveQuery query = new WaveQuery();
    3.             query.posX = x;
    4.             query.posZ = z;
    5.  
    6.             Ocean.Instance.QueryWaves(query);
    7.  
    8.             float vx = query.result.displacementX;
    9.             float vy = query.result.displacementZ;
    10.  
    11.             Vector2 velocity = new Vector2(vx, vy) * Time.deltaTime;
    12.  
    13.              //velocity *= -1.0; //you might need to flip vector.
    14.  
    15.  
    Have not checked if that works but something along that idea should work.

    The catch is that the displacement is dependant on the choppiness value on the wave spectrum. So if the choppiness is 0 then there will be no displacement and its only the waves from the spectrum that will add to the displacement value.

    The wave overlays only displace the ocean on the y axis so they have no xz displacement.

    The wave overlays do have accurate wave height queries. You need to have read/write in the textures advanced settings tick though. If you don't do this Unity wont keep a copy of the texture data on the CPU so the query cant sample from the texture and will just ignore it.

    There is also a 'ignore queries' setting on the AddWaveOverlay script. Make sure this not ticked. Its not by default so I don't think its the issue but just in case.

    Ok, cool. Looks like its almost working. Not sure why the post effect is not working.

    In the last update I added a bool in the ocean script to disable all multi-threading but didn't get a chance to have it fully working in webGL. I was planning to try and get it working in webGL for the next update.
     
  6. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    Hi , is it possible to change the water level value at runtime to simulate changing ocean levels.
    Thanks & regards
    Gus
     
  7. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Hi,

    Yes you can. On the ocean component there is a level setting. That's the sea level. You can adjust it during run time and the ocean will move up and down.
     
  8. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    So I can change the value using a script, is this a public variable?
    Thanks again
    Gus
     
  9. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    yep. Something like this

    Code (CSharp):
    1. Ceto.Ocean.Instance.level = yourSeaLevel;
     
    gibmation likes this.
  10. pi-k

    pi-k

    Joined:
    Apr 1, 2013
    Posts:
    18
    This effect is happening at any depth anywhere when you look up for me. Is there any workaround? I was thinking of 6DOF underwater movement but it's rather ruined if everything glitches out horribly at any time you look up and plan to surface.
     
  11. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    I don't have a fix for this at the moment sorry. What are you camera near and far values?

    EDIT - Also if you have not already can you update to latest Ceto version (1.1.0) as it has a bug for something related to this that may also help reduce this issue.
     
    Last edited: Mar 10, 2016
  12. pi-k

    pi-k

    Joined:
    Apr 1, 2013
    Posts:
    18
    Camera is 0.3 near 1000 far and it's Ceto 1.1.0.

    I'll go with a horizontally aligned camera with restricted upwards view for now, which might be a better solution anyway as it's less disorienting.
     
  13. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,113
    Being having the same issue, just spotted this and it worked for me.
    Hmm any way around it, pity to lose the occlusion culling.
     
  14. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Thanks. I know what the issue is and I am pretty sure I can fix it. I will try and have it resolved for the next update.

    Looks like the reflection camera might be doing the occlusion culling different than the normal camera. I will add it to the bug list.
     
    FargleBargle and John-G like this.
  15. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    680
    What I've been doing in the mean time is creating my own occlusion zones, using trigger colliders and a script that toggles rendering off for selected objects when the player isn't in them. This is great for smaller scene details, that add extra draw calls without really being visible most of the time. It also allows me to decide what should and shouldn't be included, so larger objects that might cause noticeable "popping" otherwise aren't included. I've also created a "no reflect" layer, and use it for a lot of scene objects that don't need to be included in the reflection, like smaller details and particle systems. Still, a solution that lets us use Unity's native occlusion culling again would be nice.
     
    scrawk and John-G like this.
  16. Drnkhobo

    Drnkhobo

    Joined:
    Jan 19, 2013
    Posts:
    5
    Tried the script but unity throws an error about not enough arguments for the wavequery function... I will send you an email rather ;)
     
  17. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Hmm. I checked the code before posting. Im sure its just a minor typo. Make sure you have 'using Ceto;' in the script.

    Feel free to send a email though if the issue persist.
     
  18. Drnkhobo

    Drnkhobo

    Joined:
    Jan 19, 2013
    Posts:
    5
    Thanks Scrawk, I get the same error with this:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Ceto;
    4.  
    5. public class NewBehaviourScript : MonoBehaviour {
    6.  
    7.    // Use this for initialization
    8.    void Start () {
    9.  
    10.    }
    11.  
    12.    // Update is called once per frame
    13.    void Update () {
    14.  
    15.   WaveQuery query = new WaveQuery();
    16.   query.posX = x;
    17.   query.posZ = z;
    18.   Ocean.Instance.QueryWaves(query);
    19.   float vx = query.result.displacementX;
    20.   float vy = query.result.displacementZ;
    21.   Vector2 velocity = new Vector2(vx, vy) * Time.deltaTime;
    22.   //velocity *= -1.0; //you might need to flip vector.
    23.  
    24.    }
    25. }


    With this error:

    Assets/Float.cs(15,42): error CS1729: The type `Ceto.WaveQuery' does not contain a constructor that takes `0' arguments

    Assets/Float.cs(16,26): error CS0103: The name `x' does not exist in the current context

    Assets/Float.cs(17,26): error CS0103: The name `y' does not exist in the current context


    Im probably doing this wrong here.... :D:rolleyes:
     
  19. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765

    My bad. Try this.

    Code (CSharp):
    1.     using UnityEngine;
    2.     using System.Collections;
    3.     using Ceto;
    4.    
    5.     public class NewBehaviourScript : MonoBehaviour {
    6.    
    7.        // Use this for initialization
    8.        void Start () {
    9.    
    10.        }
    11.    
    12.        // Update is called once per frame
    13.        void Update () {
    14.  
    15.       //Ocean instance will be null if ocean not in scene or has not awakened yet.
    16.       if(Ocean.Instance == null) return;
    17.    
    18.       WaveQuery query = new WaveQuery(transform.position);
    19.  
    20.       Ocean.Instance.QueryWaves(query);
    21.       float vx = query.result.displacementX;
    22.       float vy = query.result.displacementZ;
    23.       Vector2 velocity = new Vector2(vx, vy) * Time.deltaTime;
    24.       //velocity *= -1.0; //you might need to flip vector.
    25.    
    26.        }
    27.     }
    28.  
     
  20. Drnkhobo

    Drnkhobo

    Joined:
    Jan 19, 2013
    Posts:
    5
    :) Thank you!!! Will check it out now
     
  21. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    41
    Hi scrawk,

    I'm doing a network test using UNET, I can't for the life of me find a way to transmit the IOceanTime.

    #1 it won't cast to anything. if you do a .ToString() it works but then you can't cast it back.
    #2 it won't [syncvar] which with UNET is a huge thing as that's how anyone using the HLAPI would use it.
    #3 Unet apparently has a Network.time but I can't seem to use that to apply to OceanTime.

    Just wondering if there is an easy way to get this sent as a string or some other data form, or am I just not understanding some fundamental concept? lol I keep telling myself I'm not a programmer... but here I am.

    Maybe you can work some magic and get it as and GET SET? or allow it to be cast somehow... I've seen people convert DateTime to string and back... but IOceanTime doesn't cast to DateTime either.

    Any help is appreciated, scoured the net for over an hour without any luck.
     
    Last edited: Mar 13, 2016
  22. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    77
    Dearest Scrawk,

    So, there's this great new feature for VR being introduced with Unity 5.4.0 called "Single-Pass Stereo Render", that cuts draw-calls in half by rendering both eye perspectives simultaneously. Since commercial VR headsets start shipping in 2 weeks, this is going to become a high priorty for Unity devs as we update our existing projects to run at 90 FPS on the higher resolution of the consumer headsets.

    Ceto currently experiences some interesting side-effects once you enable this feature in PlayerSettings. (I believe you can test these yourself without a headset using any of the 5.4.0 betas.)

    Firstly, the Planar Reflection doesn't map correctly to either view:

    Secondly, Underwater unfortunately doesn't seem to render much but some sort of glitch when in USE_DEPTH_BUFFER mode, which is a higher priority because USE_OCEAN_DEPTH_PASS introduces artifacts around the edges of objects when in VR mode.


    Thirdly, Underwater in USE_OCEAN_DEPTH_PASS mode seems to render each eyeball twice, causing a doubling of shadows and placing the mask in the wrong position:




    I don't have any insight into how Unity is making this work behind the scenes, or even if the responsibility for the issue lies with their code. I'm very short on time and energy these days, else I'd investigate further. I hope you or someone else can figure out what's going on, as this Unity feature will soon become very important to a lot of Unity devs.
     
  23. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Ok, thanks for that. If I can reproduce it easily without a VR headset in the 5.4 beta then Im sure I can fix the issue.

    It might be a simple fix but if its not then it could take a lot longer than two weeks.

    Im not familiar with UNET or networking in general but I think your confusing the IOceanTime interface with the actual time value which is just a float. If your using networking I recommend make your own script which implements the IOceanTime interface. That way you have complete control over the time value and can use Network.Time if you like.

    Heres a example script that should help you.


    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. using Ceto;
    6.  
    7. public class OceanTimeExample : MonoBehaviour, IOceanTime //Implement the interafce
    8. {
    9.  
    10.  
    11.      /// <summary>
    12.      /// Add the now property which is the time Ceto will use.
    13.      /// This should be the time in seconds since some arbitrary
    14.      /// event like app or server start up.
    15.      ///
    16.      /// It does not really matter what value is used. As long as all
    17.      /// clients use the same value the ocean will look the same.
    18.      ///
    19.      /// </summary>
    20.      public float Now { get; set; }
    21.  
    22.  
    23.      /// <summary>
    24.      /// Has overlay been added to ocean
    25.      /// </summary>
    26.      bool m_registered;
    27.  
    28.      void Start ()
    29.      {
    30.  
    31.         if (!m_registered && Ocean.Instance != null)
    32.        {
    33.            //Add interface to the ocean if ocean has awakened.
    34.            Ocean.Instance.OceanTime = this;
    35.            m_registered = true;
    36.         }
    37.  
    38.      }
    39.  
    40.      void Update ()
    41.      {
    42.         if (!m_registered && Ocean.Instance != null)
    43.         {
    44.            //Add interface to the ocean if ocean has awakened.
    45.            Ocean.Instance.OceanTime = this;
    46.            m_registered = true;
    47.         }
    48.  
    49.         //Update the time value
    50.         Now = Time.time;
    51.  
    52.        //Use network time if you need to presuming its the time in seconds.
    53.        //Now = Network.time
    54.  
    55.      }
    56.  
    57.      /// <summary>
    58.      /// Cast time to string if your need to.
    59.      /// </summary>
    60.      /// <returns></returns>
    61.      public string TimeToString()
    62.      {
    63.  
    64.         return Now.ToString();
    65.  
    66.      }
    67.  
    68.     /// <summary>
    69.     /// Cast string back to time if you need.
    70.     /// </summary>
    71.     /// <param name="s"></param>
    72.     public void FromString(string s)
    73.     {
    74.        float t;
    75.        float.TryParse(s, out t);
    76.        Now = t;
    77.      }
    78.  
    79.  
    80. }
    81.  
    82.  
     
    olavrv likes this.
  24. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    41
    Thanks, I've used a variation of this and I can get it syncing now. I think there might be a more efficient way I'm exploring, but for now it's working :)
     
  25. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,166
    Hey everyone!

    We have had a lot of requests for having UniStorm control Ceto. So, we decided to make an example script of how to do so. The script allows you to control the wave intensity (wind speed) as well as the choppiness intensity during stormy weather types for UniStorm. The script will also fade out Ceto's specular intensity so the sun's specular light isn't visible during stormy weather types. Everything is then faded back in when storms clear up.




    Here's an example script of how to do so:
    Code (CSharp):
    1. //Ceto Controller with UniStorm
    2. //Black Horizon Studios
    3.  
    4. using UnityEngine;
    5. using System.Collections;
    6. using Ceto;
    7.  
    8. public class CetoControllerWithUniStorm : MonoBehaviour {
    9.  
    10.     //Our UniStorm reference
    11.     private GameObject uniStormSystem;
    12.     private UniStormWeatherSystem_C uniStormSystemScript;
    13.  
    14.     //The default non-precipitation specular intensity. When switching to stormy, the specular intensity (UniStorm's Sun specular intensity) will be decreased to 0
    15.     public float startingSpecularIntensity = 0.2f;
    16.  
    17.     //Our variables that hold and control the Ceto values
    18.     private float windSpeedController;
    19.     private float choppinessController;
    20.  
    21.     //Controls our caps for both stormy and normal (non-precipitation) weather types
    22.     public float windSpeedNormal;
    23.     public float windSpeedStormy;
    24.     public float choppinessNormal;
    25.     public float choppinessStormy;
    26.  
    27.     //How fast the ocean variables are manipulated
    28.     public float windSpeedStormySpeed = 0.1f;
    29.     public float windSpeedNormalSpeed = 0.1f;
    30.     public float choppinessStormySpeed = 0.01f;
    31.     public float choppinessNormalSpeed = 0.01f;
    32.  
    33.     private float specularController = 0.2f;
    34.  
    35.     //Apply your Ceto Ocean system here
    36.     public WaveSpectrum CetoOcean;
    37.  
    38.     private bool fadingInCompleted = false;
    39.     private bool fadingOutCompleted = false;
    40.  
    41.     void Start ()
    42.     {
    43.         //Find the UniStorm Weather System Editor, this must match the UniStorm Editor name
    44.         uniStormSystem = GameObject.Find("UniStormSystemEditor");
    45.         uniStormSystemScript = uniStormSystem.GetComponent<UniStormWeatherSystem_C>();
    46.  
    47.        //Set Ceto's values to what's set using this script
    48.         CetoOcean.windSpeed = windSpeedNormal;
    49.         CetoOcean.choppyness = choppinessNormal;
    50.  
    51.         //Set our variables to the current Ceto settings
    52.         windSpeedController = CetoOcean.windSpeed;
    53.         choppinessController = CetoOcean.choppyness;
    54.  
    55.     }
    56.  
    57.     void Update ()
    58.     {
    59.         //If the weather type is a storm, change Ceto's variables to stormy
    60.         if (uniStormSystemScript.weatherForecaster == 3 || uniStormSystemScript.weatherForecaster == 12)
    61.         {
    62.             if (!fadingInCompleted)
    63.             {
    64.                 windSpeedController += Time.deltaTime * windSpeedStormySpeed;
    65.                 choppinessController += Time.deltaTime * choppinessStormySpeed;
    66.  
    67.                 CetoOcean.windSpeed = windSpeedController;
    68.                 CetoOcean.choppyness = choppinessController;
    69.  
    70.                 specularController -= Time.deltaTime * 0.005f;
    71.                 Ceto.Ocean.Instance.specularIntensity = specularController;
    72.  
    73.                 if (specularController <= 0)
    74.                 {
    75.                     specularController = 0;
    76.                 }
    77.  
    78.                 if (windSpeedController >= windSpeedStormy)
    79.                 {
    80.                     windSpeedController = windSpeedStormy;
    81.                 }
    82.  
    83.                 if (choppinessController >= choppinessStormy)
    84.                 {
    85.                     choppinessController = choppinessStormy;
    86.                 }
    87.  
    88.                 if (windSpeedController >= windSpeedStormy && choppinessController >= choppinessStormy && specularController <= 0)
    89.                 {
    90.                     fadingInCompleted = true;
    91.                     fadingOutCompleted = false;
    92.                 }
    93.             }
    94.         }
    95.  
    96.         //If the weather types are normal (non-precipitation), change Ceto's variables to normal
    97.         if (uniStormSystemScript.weatherForecaster == 1 || uniStormSystemScript.weatherForecaster == 2 || uniStormSystemScript.weatherForecaster >= 4 && uniStormSystemScript.weatherForecaster < 12 || uniStormSystemScript.weatherForecaster == 13)
    98.         {
    99.             if (!fadingOutCompleted)
    100.             {
    101.                 windSpeedController -= Time.deltaTime * windSpeedNormalSpeed;
    102.                 choppinessController -= Time.deltaTime * choppinessNormalSpeed;
    103.  
    104.                 CetoOcean.windSpeed = windSpeedController;
    105.                 CetoOcean.choppyness = choppinessController;
    106.  
    107.                 specularController += Time.deltaTime * 0.005f;
    108.                 Ceto.Ocean.Instance.specularIntensity = specularController;
    109.  
    110.                 if (specularController >= startingSpecularIntensity)
    111.                 {
    112.                     specularController = startingSpecularIntensity;
    113.                 }
    114.  
    115.                 if (windSpeedController <= windSpeedNormal)
    116.                 {
    117.                     windSpeedController = windSpeedNormal;
    118.                 }
    119.  
    120.                 if (choppinessController <= choppinessNormal)
    121.                 {
    122.                     choppinessController = choppinessNormal;
    123.                 }
    124.  
    125.                 if (windSpeedController <= windSpeedNormal && choppinessController <= choppinessNormal && specularController >= startingSpecularIntensity)
    126.                 {
    127.                     fadingOutCompleted = true;
    128.                     fadingInCompleted = false;
    129.                 }
    130.             }
    131.         }
    132.     }
    133. }
    134.  
     
    Last edited: Mar 16, 2016
    olavrv, clickmatch, Peter77 and 3 others like this.
  26. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Very nice!

    Well done :)
     
  27. JJJohan1

    JJJohan1

    Joined:
    Oct 13, 2013
    Posts:
    11
    Getting the ocean into a strange state, unfortunately don't have an easy way to reproduce it, but it seems to happen when the ocean generation happens when the camera is already very close to the water's surface. I'm not touching the quality settings whatsoever or the render target resolutions.

    Notice the pixelation of the surface. The actual displacement remains unaffected.
     
  28. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,957
    ** nevermind, deleted the scripts folder and re-imported fresh, works fine.

    just noticed that with 5.4.0b10 its giving error,
    in line "public OverlayMaskedTexture foamTexture;"

    I changed it to "public OverlayFoamTexture foamTexture;"..

    then some other error,
     
    scrawk likes this.
  29. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    I thought that was kinda of a neat look so I started playing with something that could replicate the appearance. It will take some scripting to get perfect but really wasn't as hard as I expected. It uses a spot light at the top, an object with either emission or just reflecting a nearby point light, and a point light just above the water where the light aims at the surface (using a similar script to my bow wave one). I have a particle effect to make the spotlight more visible.
     
    MarcusWatson, Peter77, scrawk and 4 others like this.
  30. Imhotebkin

    Imhotebkin

    Joined:
    Feb 10, 2015
    Posts:
    15
    How did you get the spotlight to show on water? My water only reflects direct point light and reflected spotlight lights. I think it shows the spotlight sometimes when you aim it directly down but if you turn it it doesn't light up the water for me
     
  31. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    The trick is that the 'spotlight' shining on the water is actually a point light just above the surface with high intensity and small radius that is matched to the angle and distance of the spot light so that the area lit matches the size that the spotlight would be hitting. I was saying it would need to be scripted so that it could decrease intensity and increase the radius as the spotlight moves away from the water but keeps the point light at the water surface.

    With the point light on above the water surface.


    Without the point light
     
  32. Imhotebkin

    Imhotebkin

    Joined:
    Feb 10, 2015
    Posts:
    15
    lol. That's a neat little trick=) Unfortunately i have objects swimming in the lighted area so that won't work in my situation.
     
  33. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    41
    Why wouldn't it? Put a slightly larger point light slightly higher off the water surface. (ceto wave height + 3m) This will still cast light downwards... I'd say do a 2 punch combo and have a raycast from the spotlight. If the distance to the water is less than the distance to any other (disqualifying) object... use the point light off the water. else just use the spotlight itself and turn the point light off...

    This would work in situations where say a ship would be tagged so when the raycast hits it it turns the point light off... but if it's just a survivor in the water, it wouldn't... and the point light would detect that the water distance is closer than any other object and turn the point light on.. thus illuminating the water and the survivor. Might get some over-exposure on the survivor but it's better than nothing.... I'm sure you might think of some other clever methods.
     
    CaptainMurphy likes this.
  34. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Sorry, I only just saw this today. Missed it when it got posted.

    Im going to do a minor update in about 2 weeks to fix a few bugs and I will try and sort out this and the other WebGL issues then. Is this only happening in WebGL build or on a PC in the editor? Are you on Ceto version 1.1.0 or 1.0.9?
     
  35. shuao23

    shuao23

    Joined:
    Dec 19, 2013
    Posts:
    31
    Are we allowed to port this to Unreal 4?
     
  36. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    If you want. I would be very impressed if you mange to do it. It would be a lot of work.

    I would have thought Unreal has there own asset store with something like this you could buy?
     
  37. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    There is. https://github.com/UE4-OceanProject/OceanProject
     
    Peter77 likes this.
  38. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,113
  39. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I'm curious if any Ceto users tweak the settings in the Underwater component if you have night scenes? I don't know if it's an HDR thing or what, but I found that reducing the Tint value under Sub-Surface Scatter Modifier and the Intensity value under Above Inscatter Modifier makes the ocean look better at night. Otherwise there's too much of a "glow" to it, which is noticeable when the skybox is very dark.

    In a test scene that uses azure Sky, I set that tint to V = 137 (RGB 85, 71, 37) and that intensity value from 1.0 to 0.05.

    Just wondering what settings, if any, you guys use when you have darkness as an option. Like, is there a better way to handle this?

    Here's a comparison. The top row is with the default values and the bottom are my values. The columns are for 5:30 am, noon, 6:30 pm, and midnight. It might be difficult to see the differences with the images squeezed down like that. The one that's easier to see is the last column at midnight.




    On a side note, I tried out the Add Auto Shore Mask on the terrain, and it worked great. But the shoreline foam seems to glow in the dark?
     
  40. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    Some people have reported similar issues. There is a bug with the some of the ocean colours and the foam at night. I think it's a gamma/ linear issue but not sure at the moment.

    I will get to shoreline stuff at some point but until then I don't know what they will end up looking like.
     
  41. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Ah, interesting. I am running in linear color space, FWIW.
     
  42. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,113
    For darkness, I have a script that adjusts all my environment settings depending on light intensity.
    With regards to Ceto it adjusts the frensel power, the foam intensity and the reflection intensity.
    Gives a real dark ocean at night, working in linear myself.

    No worries, I have full confidence that when you get to them they will be great. :)
     
    Last edited: Mar 27, 2016
    scrawk likes this.
  43. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    There is a foam intensity setting on the ocean component. If you lower that at night it might help with the brightness issue until I work out what the bug is.
     
  44. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I did initially play with upping the Fresnel, but that seemed to make things kind of weird. I suppose if it's just at night, that could work. Maybe if @scrawk is able to pinpoint any color bugs, those sorts of workarounds won't be needed.

    Are you reducing the reflection intensity or increasing it? I'm not picturing how you'd want that to change at night.
     
  45. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,113
    All three are reduced at night to zero or about 0.02f if slight reflection is wanted so not completely black.
    The fresnel reduces the blue glow in water so not to look like it's illuminated from underneath.
    The foam intensity sorts the glowing white foam issue.
    While the reflection intensity stops the white sheen on the ocean while the rest of the environment is pitch black.

    Ceto defaults at Night:


    Ceto with the above settings reduced:
     
    Last edited: Mar 27, 2016
    scrawk and Steve-Tack like this.
  46. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    The settings I mentioned also reduce the blue glow. Lowering the Fresnel value kind of looks weird to me if there's any light at all. In my test scene, azure Sky has the moon opposite the sun, so it's never truly pitch black. It's not realistic, but that's actually pretty useful for gameplay purposes.
     
    John-G likes this.
  47. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,113
    Had a play with your settings, and have come to the conclusion that leaving Fresnel alone is actually better.
    Found that changing the Foam Intensity (Min 0.01) along with SubSurface Scatter Intensity (Min 0.2) and Above-Inscatter intensity (Min 0.02) gives very good results for darkness.
    Thanks Steve for pointing that out, much better result indeed.
     
    Last edited: Mar 28, 2016
  48. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    77
    If you get close to the ocean's surface, the Planar Reflection renders objects strangely. (Some foreground objects vanish, etc.)

    Adjusting the Clip Plane Offset to a number like "-2" helps, but then the reflection offset isn't ideal.

    I've found that modifying the following method in PlanarReflection.cs like this fixes the issue:
    Code (CSharp):
    1.         Matrix4x4 CalculateObliqueMatrix(Matrix4x4 projection, Vector4 clipPlane) {
    2.             Vector4 q = projection.inverse * new Vector4(
    3.                 Mathf.Sign(clipPlane.x),
    4.                 Mathf.Sign(clipPlane.y),
    5.                 1.0F,
    6.                 1.0F
    7.                 );
    8.             Vector4 c = clipPlane * (2.0F / (Vector4.Dot(clipPlane, q)));
    9.             projection[2] = c.x - projection[3];
    10.             projection[6] = c.y - projection[7];
    11.             projection[10] = c.z - projection[11];
    12.             projection[14] = c.w - projection[15];
    13.             // workaround for goofy reflection result when close to water surface
    14.             if (projection[14] > 0f) {
    15.                 projection[14] *= -1f;
    16.                 if (projection[14] > -0.1f)
    17.                     projection[14] = -0.1f;
    18.             }
    19.             return projection;
    20.         }
    I don't understand this code very well, so there may be a better solution, but this works well-enough for my purposes.
     
  49. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,113
    @scrawk not sure if wind direction is working correctly, appears to be of by -90deg.
    Trying to get 0 deg = (North) positive Z axis ? Tried changing the CalculateWindDirVector() routine with no luck.
    When wind is set to 0 deg, it appears to move in the negative X Axis.
     
  50. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    765
    @FargleBargle reported the same issue at top of last page. It turned out related to occlusion culling. Are you using occlusion culling?

    I think what is happening is that since the reflection camera uses a oblique rojection matrix it culls objects differently than the main camera so they sometimes get culled when the main cam still renders them.

    Thanks for the fix with the matrix. I will have a look into it.

    I went to have a look at the Single-Pass Stereo Render issue today but realized that you need at least windows 8.1. Im still on windows 7 so Im upgrading to windows 10 at the moment.

    I found the cause of the bright foam and blue glow at night issue today. I can fix the foam easy and I think I can reduce the glow but I dont think I can get ride of it completely.

    I had a look but to me it seems to be working fine. At 0 the waves should move towards the neg x axis and they should move clockwise as the angle changes.

    So at 90 they should move in the pos z axis.

    Are you trying to change the code so that 0 is the pos z axis?

    WindDir0.jpg


    WindDir90.jpg
     
    John-G likes this.
unityunity