Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

The Community Ocean Shader (Open Source) Unity 5

Discussion in 'Shaders' started by laurent-clave, Nov 30, 2015.

  1. Kobald-Klaus

    Kobald-Klaus

    Joined:
    Jun 20, 2014
    Posts:
    53
    What would be the best approach to implement a map of waveheights so that one could define areas where there are no or little waves and other areas with high waves? There are these calc*** functions in the ocean.cs. I guess it should go there. Any thoughts?
     
  2. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    How do you do that? Just using "NATIVE; SIMD; THREADS" seem to have worked for me...

    Was also thinking of freezing some parts of the water and adding Ice Flows. Found this cool Ice Flow Shader but not sure if it will work and how to use it with this. The developer doesn't know too so I need to do some more research. Would appreciate if anybody can share some tips. :)
     
  3. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,782
    I finally got a smooth FPS character on the deck of a moving ship. Here's the real interesting thing. In the video my FPS character is actually on that floating static ship you can see in the scene (not on the moving one). Because of a camera trick and making one camera sync with another it appears I'm on the deck of the moving ship (that does have physics). Now in production of course I'd hide all rendering of the static ship. All collision and physics is done on that static ship and the crew members on the deck of the moving ship are just "proxies" of their physics based counterparts (this way I can collide with them, etc).

    Another thing I had to do was set a custom input for the ship's steering as it conflicted with the moving of the FPS character. It was super simple. I just set a new input axis in the Input Manager called "Ship_Steer" and used the keyboard brackets to turn the ship. This way I can run around and steer the ship. This is not a project I have in production at the moment, it was an experiment to use this beautiful ocean. I've found that I feel like I'm actually on a ship at sea, so this experiment might have some merit in moving forward to a vertical slice.

     
    sharkapps, twobob, llJIMBOBll and 4 others like this.
  4. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,236
    Have you tried this?


    EDIT: When I added the lines "NATVE; SIMD; THREADS" in the Scripting Define Symbols filed under Edit -> Project Settings -> Player -> Other Settings (PC, MAC, & Linux), the dark square patch seem to have disappeared and I feel the game ran a little bit faster than before. :D
     
    RendCycle likes this.
  5. Kobald-Klaus

    Kobald-Klaus

    Joined:
    Jun 20, 2014
    Posts:
    53
    Maybe the screenshot helps. see the red marks. As I wrote: It´s just a big square below the surface with a material that emits some extra color. I also added a bumpmap which gives some nice scattered colors. You can also put a submerged terrain. This makes the "ghost" sqare disappear.
     

    Attached Files:

    RendCycle and JamesArndt like this.
  6. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Will try this out if ever the problem appears again on my game. So far, the square patch is still gone by just using "NATIVE; SIMD; THREADS". Nevertheless, thanks for sharing the solution! :)
     
  7. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,236
    I am finally finishing my job obligations and will focus on this now.

    First priority is the projected grid.
     
    st-VALVe, Emre_U, twobob and 2 others like this.
  8. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Anybody had success integrating this with Enviro - Sky & Weather asset or any other weather system available in the market for that matter?
     
  9. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    elias_t likes this.
  10. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    Hi James,

    Very nice work!!
    I'm trying to inculde a FPS in the boat but the gravity affects too much the boat movements.
    How do you do it? or pehaps Elias know how to do it
     
    JamesArndt likes this.
  11. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,782
    The trick is to not run any of the player physics on the actual boat physics object. So by default you have the Community Ocean buoyancy object that is the boat. It's got a big collider and it's running the physics for "floating" on the ocean waves. You do not want to attempt to put another physics object on top of that. By that I mean a Character Controller or a Rigidbody FPS or 3rd person controller. The two will usually be wonky and not work, it's the age old moving platform issue. An easy workaround is the trick I'm doing. You have a duplicate of your physics boat, but remove all scripts from it, remove any gravity from the Rigidbody on the boat. On this duplicate boat create nice form-fitting collision for all of the things the player might collide with on or below deck, i.e. walls, stairs, cannons, buckets, etc. You can also hide all of the visuals for this static boat (no need to render it's art at all). Place your FPS or 3rd person controller on this static duplicate boat. Now you can run around on a static boat, collide with things, jump around, etc. This is where the visual trick comes in. Disable rendering of the default camera that is being used for your FPS character or 3rd person character. Create a new camera, and make it a child of the actual Community Ocean buoyancy boat.

    The new camera is on the deck or under deck of your actual boat that moves over the ocean. Make sure this is the camera that is rendering your player and world (not the one that is on the static duplicate). Now you'd create a very simple script that would do the following: Make the transform of this new camera follow the transform of the camera on your FPS or 3rd person character. Make it also match the rotation of the original FPS or 3rd person camera. Since this new camera is a child object you'd most likely use LocalRotation vs. Rotation in your scripts. Now when you run around on the static duplicate ship, you will actually see yourself on board the ship that is traveling across the ocean. All of the motions of your character will match the motions you are doing on the static ship. You will want to apply this same script to the motion and rotation of your player character...so the script is applied to both the camera and the player objects so you can sync the movement and rotation of both. Once you set this up, you will have zero physics issues with your character on the deck of the moving ship. You can move all over the ship, both above and below deck smoothly.

    An example script to do this would look like:


    Code (CSharp):
    1. public class SyncMovement : MonoBehaviour {
    2.  
    3.     public GameObject copy;
    4.  
    5.     void Update ()
    6.     {
    7.         transform.localPosition = copy.transform.localPosition;
    8.         transform.localRotation = copy.transform.localRotation;
    9.     }
    10. }
     
    twobob likes this.
  12. itsnottme

    itsnottme

    Joined:
    Mar 8, 2017
    Posts:
    73
    Hey, I just found this shader and I love it, but I have 2 issues.

    The first is the cpu usage, it is quite high with the current settings I am using, but I am not sure what to change to lower it. I would like the best look but don't care about the waves and other things. I am using it on PC.

    Second issue is that when the camera gets close to the ocean, tiles start to change shape. I suspected that it is the follow camera option, but I unchecked it and same problem.
     

    Attached Files:

    • 3.PNG
      3.PNG
      File size:
      700.9 KB
      Views:
      490
  13. itsnottme

    itsnottme

    Joined:
    Mar 8, 2017
    Posts:
    73
    Adding NATVE;SIMD;THREADS to settings reduced ocean update cpu time from 7 ms on average to 1.2 ms.

    But I still have the tile problem.
    3.png happens sometimes (when reflection is on) when moving the camera.
    4.png is when getting very close to the ocean.
     

    Attached Files:

    • 2.PNG
      2.PNG
      File size:
      1.7 MB
      Views:
      618
    • 3.PNG
      3.PNG
      File size:
      1.4 MB
      Views:
      681
    • 4.PNG
      4.PNG
      File size:
      696.5 KB
      Views:
      599
    RendCycle and JamesArndt like this.
  14. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    H
    Hi,

    Thank you so much!!! I will try to play with it
     
    JamesArndt likes this.
  15. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    I've successfully used Enviro with this. But there is always an OnRenderImage console warning when I enable CloudReflections and run the game.

    Code (CSharp):
    1. OnRenderImage() possibly didn't write anything to the destination texture!
    My findings point to a piece of custom code in Enviro when generating the cloud reflections. The 2 lines I indicated below, when switched, removed the OnRenderImage console warning. But I noticed it made a sort of "spotlight" reflection on the water from time to time especially when moving. By any chance, has someone encountered this before and has found a fix? Posting this here as a last resort.

    Switch line of codes from top to bottom to remove OnRenderImage console warning:
    Code (CSharp):
    1. Graphics.Blit (source, destination, blitMat);
    2. Graphics.Blit (subFrameTex, prevFrameTex);
    The OnRenderImage function that partly handles the Cloud Reflections:

    Code (CSharp):
    1.  
    2.     [ImageEffectOpaque]
    3.     public void OnRenderImage(RenderTexture source, RenderTexture destination)
    4.     {
    5.    
    6.         if (EnviroSky.instance == null)
    7.         {
    8.             Graphics.Blit(source, destination);
    9.             return;
    10.         }
    11.  
    12.         if (EnviroSky.instance.cloudsMode == EnviroSky.EnviroCloudsMode.Volume || EnviroSky.instance.cloudsMode == EnviroSky.EnviroCloudsMode.Both)
    13.         {
    14.             StartFrame();
    15.  
    16.             if (subFrameTex == null || prevFrameTex == null || textureDimensionChanged) {
    17.                 CreateCloudsRenderTextures(source);
    18.             }
    19.  
    20.             //RenderingClouds
    21.             RenderClouds(subFrameTex);
    22.  
    23.             if (isFirstFrame)
    24.             {
    25.                 Graphics.Blit(subFrameTex, prevFrameTex);
    26.                 isFirstFrame = false;
    27.             }
    28.  
    29.             //Blit clouds to final image
    30.             blitMat.SetTexture("_MainTex", source);
    31.             blitMat.SetTexture("_SubFrame", subFrameTex);
    32.             blitMat.SetTexture ("_PrevFrame", prevFrameTex);
    33.             SetBlitmaterialProperties ();
    34.  
    35.            Graphics.Blit (source, destination, blitMat);
    36.             Graphics.Blit (subFrameTex, prevFrameTex);
    37.                    
    38.  
    39.             FinalizeFrame ();
    40.  
    41.         } else
    42.         {
    43.             Graphics.Blit(source, destination);
    44.         }
    45.  
    46.     }
    47.  
    Anyhow, I have another question on Community Ocean. How can you get the current Water Surface Height in a particular position? I tried using the built-in functions GetHeightChoppyAtLocation2 and GetWaterHeightAtLocation2 but it produces the same Console Error:


    Here is how I tried to call the function from another script.

    Code (CSharp):
    1.  waterSurfaceHeight = GameObject.FindGameObjectWithTag ("Ocean").GetComponent<Ocean> ().GetHeightChoppyAtLocation2 (transform.position.x, transform.position.z);
    Any assistance would be highly appreciated. Thanks!
     
    Last edited: Jul 10, 2018
  16. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Silly me, I just had to transfer the code from Start to Update section to get the current Water Surface Height! :D
     
    twobob likes this.
  17. grobonom

    grobonom

    Joined:
    Jun 23, 2018
    Posts:
    177
    this stuff is not amazing !
    It's simply AWESOME !!!! :O
    i'll have to try it out very soon ! and hope it don't burden webgl too much !
    ( knowing that webgl if even burdened by a fly :p )
    congratulation for this wonderfull work !!!!
     
  18. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Regarding Waves Settings, is there a built-in function that can be used to slowly transition from one value to another? I tried changing the values within Ocean.cs but it abruptly changes the water and throws the position of my boat. The closest functions I found are SetWaves and updVars but I think they are used for other things as I can't seem to make them work. :confused:



    Edit: I think I found it but it will still require some modifications to control the duration of transition: Lerp (float from, float to, float value)
     
    Last edited: Jul 13, 2018
  19. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    3 days have gone, some hairs have fallen off, and I still can't figure this out. :confused: I tried hijacking the waveScale value through Update/FixedUpdate section by inserting some bool checking and the piece of code below to Lerp the waves to my desired height before updNoThreads function and the rest of the code are executed. This seemed to work and waves slowly build up to a height I specify. But once the Coroutine is over, it abruptly resets the waveScale value back to the original specified in the Inspector. I used a callback for the Coroutine by the way.

    Code (CSharp):
    1. IEnumerator WavesChanger (float from, float to, float duration, System.Action<float> callback = null) {
    2.         float timeToStart = Time.time;
    3.         while (waveScale != to) {
    4.             waveScale = Mathf.Lerp (from, to, (Time.time - timeToStart) * duration);
    5.             callback (waveScale);
    6.             yield return null;
    7.         }
    8. }
    What am I missing? If you guys have some clue please let me know. Thanks in advance!
     
  20. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Got it! The problem was simple... I was using the wrong variable!!! hahaha Here are the notable variables to affect in order to change the water waves in runtime:
    • scale
    • choppy_scale
    • speed
    • waveDistanceFactor
    At first, I never considered opening up the OceanGeneratorInspector script file... :D
     
    twobob and odival like this.
  21. itsnottme

    itsnottme

    Joined:
    Mar 8, 2017
    Posts:
    73
    Is there any way to fix these 2 problems? I can't seem to find a fix.
     
  22. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    92
    So I have a similar requirement. I want to limit wave height and calm things down near islands but increase intensity away from islands/spots. Have you made any progress on this or does anyone have some thoughts as I delve into it. Granted I can use RendCycles posts to adjust the wave height etc as the boat moves out into the ocean however this means the tiles around the islands are also being adjusted which is an issue if you can see them still ie spy glass or just near by.

    Thanks.
     
  23. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    I'm not sure if it is possible to have more than one wave setting at a given time because I guess the scale, speed, choppiness, and wave distance variables control all the ocean meshes. Maybe there is a work around if you use a Spy Glass to look at another ocean area... By quickly changing the 4 wave property values to a calmer water when the player view switches to the Spy Glass and then switching back to the original values when he goes back to normal view. But I think one challenge there would be how to avoid affecting the physics of the other buoyant objects that touches the water when the switch happens. Because in my experience, if you abruptly change the values of the Wave Properties, it usually messes up any touching objects (that uses the included Buoyancy script) and throws them around. :eek:

    Just like in Enviro when defining Weather Zones, It would be great if the Community Ocean Shader also has a feature that can specify various Wave Zones which can have different Wave Property values that transition seamlessly with adjacent waves. Then again, zone weather in Enviro is only visible when the player enters that Zone... Thus I'm guessing it will be very difficult for Ocean to have that kind of feature and will probably require a major overhaul. If ever someone will be able to release that sort of water asset, it will probably be a hit in the Asset Store. :)

    Edit: After considering this further, I think it might be possible to have calmer waves near terrains if there is a way to isolate the 4 Wave Property values for selected waves and then manipulate them. I am guessing this can be done by getting the location of the Foams that are generated for the terrains. I'm just not sure how difficult it will be since I don't know how the movement of the waves are being controlled and whether there is an easy way to integrate more than one set of Wave Property variables to the Ocean meshes.
     
    Last edited: Jul 26, 2018
  24. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    One of the weird things I'm experiencing about this Community Ocean Shader is sometimes "Array Index is Out of Range" errors suddenly appear out of the blue when you run the game. After clearing up the Console, the game runs fine again after a while. Not sure why this happens (pls. refer to attached image for more info). Is anybody experiencing this as well?
     

    Attached Files:

  25. rhamoud

    rhamoud

    Joined:
    May 20, 2013
    Posts:
    18
    Hopefully someone can help me with this but i cant seem to figure out why the Horizon is pixelated when using this plugin (See attached Photo). I have tried to mess with the fog settings with no luck and I have bumped up the anti-aliasing under the render settings to 8x with little to no difference. Ultimately I would love to figure out a way to blur out the horizon as it meets the skybox.
     

    Attached Files:

  26. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Not sure if you've already tried this... Do you use another asset to render the Clouds reflecting in the water? If yes, maybe you can try disabling / enabling the script that does that to see whether it will affect the pixelation of the horizon. For me, the weather system I use helped in seamlessly fading the sky horizon with the water. But before that, I think I also got success using the free Ultra Skybox Fog.
     
  27. rhamoud

    rhamoud

    Joined:
    May 20, 2013
    Posts:
    18
    I am not using anything special to render the skybox, it is just the default dawn dusk skybox included in the ocean sample project.
     
    Last edited: Jul 30, 2018
  28. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    I haven't experienced that but a similar thing wherein the horizon did not look right. I was able to hide it by using the aforementioned assets.

    Anyhow another issue I have with Ocean is when starting up the scene, bouyant objects get bounced around until after the water has finished loading. To those interested, my solution was simply placing a delay in the Buoyancy.cs script's Start() section by moving all the codes therein to an IEnumerator and disabling/enabling gravity & iskinematic. It's not elegant and maybe there is a better solution but for now this works for me.

    Here is the code that I used in Start():

    Code (CSharp):
    1.  
    2. void Start () {
    3.         //-- To prevent abrupt loading of object and messing up Gravity at startup...
    4.         rrigidbody = GetComponent<Rigidbody> ();
    5.         rrigidbody.useGravity = false;
    6.         rrigidbody.isKinematic = true;
    7.         StartCoroutine (WaitForOcean (true));
    8. }
    Here is the IEnumerator code:

    Code (CSharp):
    1.  
    2.     IEnumerator WaitForOcean (bool _loadNow) {
    3.  
    4.         //-- Wait before loading Gravity...
    5.         yield return new WaitForSeconds (0.5f);
    6.         rrigidbody.isKinematic = false;
    7.         rrigidbody.useGravity = true;
    8.  
    9.         //-- The original Buoyancy code in the Start section begins here. RB initialization moved up to Start.
    10.         if (!_renderer)
    11.         {
    12.             _renderer = GetComponent<Renderer> ();
    13.             if (!_renderer)
    14.             {
    15.                 _renderer = GetComponentInChildren<Renderer> ();
    16.             }
    17.         }
    18.  
    19.         if (_renderer && renderQueue > 0) _renderer.material.renderQueue = renderQueue;
    20.  
    21.         if (!_renderer)
    22.         {
    23.             if (cvisible) { Debug.Log ("Renderer to check visibility not assigned."); cvisible = false; }
    24.             if (wvisible) { Debug.Log ("Renderer to check visibility not assigned."); wvisible = false; }
    25.             if (svisible) { Debug.Log ("Renderer to check visibility not assigned."); svisible = false; }
    26.         }
    27.  
    28.         if (dampCoeff < 0) dampCoeff = Mathf.Abs (dampCoeff);
    29.  
    30.         //rrigidbody = GetComponent<Rigidbody> (); //-- Commented out and moved up to "Start ()" for initialization
    31.  
    32.         useGravity = rrigidbody.useGravity;
    33.  
    34.         if (interpolation > 0)
    35.         {
    36.             interpolate = true;
    37.             iF = 1 / (float) interpolation;
    38.             intplt = interpolation;
    39.         }
    40.  
    41.         if (SlicesX < 2) SlicesX = 2;
    42.         if (SlicesZ < 2) SlicesZ = 2;
    43.  
    44.         ocean = Ocean.Singleton;
    45.  
    46.         rrigidbody.centerOfMass = new Vector3 (0.0f, CenterOfMassOffset, 0.0f);
    47.  
    48.         Vector3 bounds = GetComponent<BoxCollider> ().size;
    49.  
    50.         float length = bounds.z;
    51.         float width = bounds.x;
    52.  
    53.         blobs = new List<Vector3> ();
    54.         prevBoya = new List<float []> ();
    55.  
    56.         int i = 0;
    57.         float xstep = 1.0f / ((float) SlicesX - 1f);
    58.         float ystep = 1.0f / ((float) SlicesZ - 1f);
    59.  
    60.         sinkForces = new List<float> ();
    61.  
    62.         float totalSink = 0;
    63.  
    64.         for (int x = 0; x < SlicesX; x++)
    65.         {
    66.             for (int y = 0; y < SlicesX; y++)
    67.             {
    68.                 blobs.Add (new Vector3 ((-0.5f + x * xstep) * width, 0.0f, (-0.5f + y * ystep) * length) + Vector3.up * ypos);
    69.  
    70.                 if (interpolate) { prevBoya.Add (new float [interpolation]); }
    71.  
    72.                 float force = Random.Range (0f, 1f);
    73.                 force = force * force;
    74.                 totalSink += force;
    75.                 sinkForces.Add (force);
    76.                 i++;
    77.             }
    78.         }
    79.  
    80.         // normalize the sink forces
    81.         for (int j = 0; j < sinkForces.Count; j++)
    82.         {
    83.             sinkForces [j] = sinkForces [j] / totalSink * sinkForce;
    84.         }
    85.     }
    86.  
    Edit: Upon testing, these codes seem to have lessened the "Array Index is Out of Range" Console Errors that I previously reported. I experienced it once only since then. Player's Boat spawning under the water from time to time does not happen anymore as well. I guess those were being caused by Buoyant objects clashing with the physics of the Ocean on startup.
     
    Last edited: Jul 31, 2018
    twobob likes this.
  29. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Another weird thing I am experiencing with Ocean is sometimes, when I do a MOUSE LOOK, these white squarish icons with rounded corners appear on-screen while my Boat is moving. It looks like they are loading something and disappears after a while. I still don't have any idea what those are. Before I was able to make them disappear by adjusting the Buoyancy settings. But now, they appear more frequently.
     
    Last edited: Jul 31, 2018
    JamesArndt likes this.
  30. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,782
    I've seen this as well, especially at low glancing angles viewing the ocean tiles. I'm curious if there is a fix or anyone has an idea what is occurring with that?
     
    RendCycle likes this.
  31. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    Hello!!

    Does anybody knows how to detect that a gameobjet is in the surface of the water or not?

    Thanks in advance and best regards
    Héctor
     
  32. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Hi Hector! I'm no expert but here is what you can try: Create a script to get the current Y Transform position of the Object then compare the resulting value from the current Ocean's Water Surface Height by using built-in functions in Ocean.cs script. There are several available there depending on how accurate the result you need. Based on comments within, the GetChoppyAtLocation2 function is specified to be the most accurate but slower. Now the final value you get after comparison should help inform you if the Object is over or under water. Where you've placed the pivot point (or center of mass?) of your Object I think should also be considered in the calculation so you might also need to use an Offset.

    May I ask, have you experienced any white squareish icons appearing on your game from time to time as I reported a few posts above?
     
  33. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    Thank you so much for your answer.

    I did not experieced with these white squareish icons. I'm playing with very low resolutions for mobile and I did not realize about that.

    If I find something that could help I will post it.
     
  34. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    On further testing, I noticed the white squarish icons only appear when using any Default shader lod with "(alpha)" in its name (at least in my case). That's shader numbers 1, 6, and 7. I am guessing this is because transparent shaders has additional overhead to use.

    Thanks for the reply. It gave me the idea to do this test. Good luck on your game! :)
     
    Last edited: Aug 3, 2018
    twobob and JamesArndt like this.
  35. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    I've experienced a bug.
    I have a third person controller, every time I move the camera looking to the ship it seems the ship fall down into the water.

    Do you know the reason?
     
  36. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    hmm... its difficult to say what the problem is without more info. But I suggest checking how the ship falls down into the water. If its like being caused by gravity (bouncy), maybe you can look into the bundled Buoyancy.cs script if you are using it and how it interacts with your camera movement code.
     
  37. rbeyer3

    rbeyer3

    Joined:
    Apr 3, 2018
    Posts:
    2
    I'm having an issue, Unity 2018.2.2f, the wake of the ship seems to be duplicated in every tile:

    WakeDuplication.PNG

    The wake exists in every ocean tile visible to the camera, in all directions. I'm not sure if this is a problem with 2018.2.2f or older versions but I'm wondering what the fix may be? If necessary I'd like to turn off the wake but I can't seem to find an option for that either.
     
  38. berkantoptas

    berkantoptas

    Joined:
    Apr 19, 2018
    Posts:
    2
    @rbeyer3 I have same problem.Can someone help ?
     
  39. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    Don't add "NATIVE; SIMD; THREADS" while it's running...
    Cos that would be really stupid and you would crash your client.

    Still who would be dumb enough to do that? right?
     
    hopeful likes this.
  40. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    So, how did people get around the bumpy horizon again?

    Work nice tho with a bit of massage
    upload_2018-8-25_19-13-27.png

    upload_2018-8-25_19-15-16.png
     
  41. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    never mind. Faffing with the Fixed Disk, Far LOD Y-offset and Wave Scale got me what I need
    upload_2018-8-26_0-0-43.png
     
    hopeful likes this.
  42. Kobald-Klaus

    Kobald-Klaus

    Joined:
    Jun 20, 2014
    Posts:
    53
    No, I have no idea, where to dig into. I am currently trying to bring my app into a functioning alpha state. So no time to fiddle arround with the waves.
     
  43. am_jooz

    am_jooz

    Joined:
    Jun 12, 2018
    Posts:
    7
    Hi all,
    I am using the Ocean shader in my current project with Unity 2017 and everything went smoothly so far.
    However, I upgraded Unity to version 2018 and are now experiencing a huge number of wild crashed of the editor, caused by an access violation of ocean.dll. The log reports the following error:

    Unity Editor by Unity Technologies [version: Unity 2018.2.3f1_1431a7d2ced7]
    ocean.dll caused an Access Violation (0xc0000005)
    in module ocean.dll at 0033:a6424140.

    Error occurred at 2018-08-29_212218.
    C:\Program Files\Unity\Editor\Unity.exe, run by .

    36% physical memory in use.
    16384 MB physical memory [10462 MB free].
    2631 MB process peak paging file [2313 MB used].
    1645 MB process peak working set [1417 MB used].

    System Commit Total/Limit/Peak: 7140MB/18816MB/11536MB
    System Physical Total/Available: 16384MB/10462MB
    System Process Count: 188
    System Thread Count: 2926
    System Handle Count: 89782

    Read from location 0000000000000000 caused an access violation.

    Context:
    RDI: 0x0000000000000000 RSI: 0x0000000000000000 RAX: 0x0000000000000400
    RBX: 0x0000000000000000 RCX: 0x0000000000000400 RDX: 0x00000000a5167024
    RIP: 0x00007ff9a6424140 RBP: 0x00000000005fd6e0 SegCs: 0x0000000000000033
    EFlags: 0x0000000000010216 RSP: 0x00000000005fd620 SegSs: 0x000000000000002b
    R8: 0xffffffff5ae98fe0 R9: 0x0000000000001000 R10: 0x00000000a5167020
    R11: 0x0000000000001000 R12: 0x0000000000000000 R13: 0x000000007b9ce8e0
    R14: 0x00000000005fdce0 R15: 0x000000001f3c9e80

    Bytes at CS:EIP:
    41 8b 44 10 fc 89 42 fc 41 8b 04 10 89 02 41 8b
    Mono DLL loaded successfully at 'C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll'.

    Stack Trace of Crashed Thread 17924:
    0x00007FF9A6424140 (ocean) fft1
    0x000000004502F00C (Assembly-CSharp) uocean.fft1()
    0x000000004502EE7B (Assembly-CSharp) uocean._fft1()
    0x0000000043E19653 (Assembly-CSharp) Ocean.updWithThreads()
    0x0000000043E18F3B (Assembly-CSharp) Ocean.Update()
    0x0000000068879A98 (mscorlib) System.Object.runtime_invoke_void__this__()
    0x00007FF992A1A5CB (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
    0x00007FF9929A1AE2 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2915] do_runtime_invoke
    0x00007FF9929AAACF (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2962] mono_runtime_invoke
    0x0000000140C0500A (Unity) scripting_method_invoke
    0x0000000140BFD1C0 (Unity) ScriptingInvocation::Invoke
    0x0000000140BB2EB8 (Unity) MonoBehaviour::CallMethodIfAvailable

    Does anybody here have some idea how to fix that? I am asking here just in case before starting the ambitious project of downgrading my Unity version...

    Thanks a lot for your help/

    Best,
     
  44. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    The previous version before the August 2018 Github update seem to have worked for me in Unity 2018.1.6. If using Unity 2018.2+, you might want to check out Crest, a new open source ocean renderer.
     
  45. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,236
    Hi.

    I tested it with Unity2018.2.4f1 and have found no issues.

    Could you share your ocean settings?
     
    JamesArndt likes this.
  46. am_jooz

    am_jooz

    Joined:
    Jun 12, 2018
    Posts:
    7
    Thanks for your feedback!

    Attached are my current settings. Two things to note here: I did not test it yet with the very last Unity version (today is 2.6f1). And I did not update either with the last commit from git commit (Aug 25).
    The crashes are not happening every time, but I would say at least 50% of the time, and so far only in editor mode.

    Screen Shot 2018-09-03 at 10.50.11.png
     
  47. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,236
    Ok.

    I noticed that I get randomly null reference exceptions when the buoyancy script tries to reposition some buoyant objects that were not visible and get visible again.

    I will update the repo with a fix.

    Line 151 of Buoyancy.cs

    Code (CSharp):
    1.             //put object on the correct height of the sea surface when it has visibilty checks on and it became visible again.
    2.             if(visible != lastvisible) {
    3.                 if(visible && !lastvisible) {
    4.                     if(Time.frameCount-lastFrame>15) {
    5.                         //float off = ocean.GetChoppyAtLocation(transform.position.x, transform.position.z);
    6.                         //float y = ocean.GetWaterHeightAtLocation2 (transform.position.x-off, transform.position.z);
    7.                         float y = ocean.GetHeightChoppyAtLocation2(transform.position.x, transform.position.z);
    8.                         transform.position = new Vector3(transform.position.x, y, transform.position.z);
    9.                         lastFrame = Time.frameCount;
    10.                     }
    11.                 }
    12.                 lastvisible = visible;
    13.             }
     
    hopeful and RendCycle like this.
  48. am_jooz

    am_jooz

    Joined:
    Jun 12, 2018
    Posts:
    7
    Thanks for the help! I will check that last mod.
     
  49. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Is it possible to add an isTrigger collider to generated Ocean LOD tiles? Planning to add underwater effects.

    Edit: Was able to add basic underwater effects using another method. I used the Water Surface Height info instead to determine the active Camera's Y position and activate the effects when it is below the ocean.
     
    Last edited: Sep 16, 2018
  50. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    329
    Hello! I am working with two Cameras in one Scene. I noticed the Ocean's body of water (mesh) kept flashing/flickering on the Camera with a lower Depth value (ex: -10) when compared to the other Camera on top which has a higher Depth value (ex: 10) which looks normal. Both Cameras uses Unity's Post Processing Stack v1 and removing them doesn't help.

    Would anybody know a fix/solution to this kind of problem?

    Edit: Was able to find a fix by either turning off Reflection (and/or Refraction) or reducing the value for Every X Frames down to 1 in consequence of having lower FPS. But lowering the Texture Size XY to 256 x 128 seem to have increased the FPS a little.

    Also discovered increasing the value of the Reflection Clip Plane Offset to 1 or 1.2 seem to have lessened/removed any noticeable artifacts that pops up from time to time.

    Still, I wish there was a way to specify more than one GameObject in the Follow field. This is so the seamlines or rather ocean tile separation is not that noticeable in the other Cameras as well and the mists will still be visible in them.
     

    Attached Files:

    Last edited: Sep 19, 2018
unityunity