Search Unity

Ceto (Scrawks Ocean)

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

  1. IronDuke

    IronDuke

    Joined:
    May 13, 2014
    Posts:
    132
    You might be able to use the heightmap of the waves or something like that, so that the caustics match the waves.
    I'm not sure if that is plausible. I'm just a random game developer. :cool: That's what I've give a try though.

    --IronDuke
     
    scrawk likes this.
  2. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    82
    @scrawk Nice work on the caustics! Those will add a better sense of depth near shorelines. :)

    Not sure procedural generation is worth the effort, as refraction distortion might make a decent animation "good enough". Try them on an actual shoreline with foam and see how it goes? Although, you know far more about generating chaotic waveforms than I do, so maybe it won't be too difficult...

    FYI, I fussed with trying to get rid of the white pixel edges on my shark's underwater body for a while by modifying Ceto settings, code, and shaders, and never got it just right. (This is using the DEPTH_BUFFER. Thought adding bilinear to the TemporaryRT or anti-aliasing would do something, but nope.) Found a workaround by reducing the _Color of my ocean floor material to grey from white. (Love that white sand though.) Not sure exactly what's going on there, but thought it worth mentioning, if only as a workaround for others that might encounter it.

     
  3. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Yeah, thats quite hard to remove.

    The problem comes from the refraction distortion. Basically the uvs are distorted when sampling the screen grab to give that watery effect. Problem is the depth value for the object is also need to apply the underwater effect so the depth is sample with the distortion as well.

    Sometimes around the edge the distorted screen color does not end up matching with the depth value. In this case the distortion has sampled the ocean floor but its used the depth value for the shark.

    The mismatch is probably a mixture of precision issues and because the depth buffer cant be sampled the same way as the screen buffer.

    The function where this happens is in the OceanUnderwater.cginc file and is called OceanColorFromAbove.

    I have not been able to remove the issue but there is one work around. You can remove the distortion from the depth buffer. In that function there is this line...

    float2 oceanDepth = OceanDepth(screenUV, distortion, surfacePos, surfaceDepth);

    If you remove the distortion like so..

    float2 oceanDepth = OceanDepth(screenUV, half3(0,0,0), surfacePos, surfaceDepth);

    It should (i think, just guessing here) remove the specks but the trade off is the underwater effect will not be correct but its hard to notice except around the edges of objects and it wont be as bad as the specks. Decreasing the refraction distortion will also help.

    The caustics are now done and they turned out quite good. I found that distorting the caustic texture with the wave normals made it look quite realistic so I dont think a procedural caustic texture will be worth it.
     
    FargleBargle, hopeful and John-G like this.
  4. IronDuke

    IronDuke

    Joined:
    May 13, 2014
    Posts:
    132
    :D
    Glad that helped!

    --IronDuke
     
  5. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    So before I go breaking things I thought I'd ask here.. you saw my previous post about the game I'm working on with the hex grid. I was wondering if it was feasible to make a custom shore mask.

    I tried making a 1024 tex in photoshop by modifying a screenshot. In Unity units my grid is about 43wx34h so I added the shore mask script to the grid's parent.. but I can't see anything on the scene. I set the height and width of the shore mask to 43x34. If I play with it in run time I can see a yellow bounding box on my grid parent and if I modify the parameters i can see the bounding box resize, but it's not doing anything to the ocean.

    Any ideas?


    Edit: Got a warning, but not sure what script I need to change to fix it.

    Ceto (1.1.0) Warning:</color> Can not query overlays height mask if read/write is not enabled
    UnityEngine.Debug:Log(Object)
     
    Last edited: Apr 28, 2016
  6. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Sounds like the texture has a empty alpha channel. Its the alpha channel that Ceto will sample.

    Click on the the texture and go to the advanced settings. Then click alpha from grey scale. It should work then.

    That warning just means that if you dont have 'read/write' enabled (also in the advanced setting) then Ceto cant sample from the texture in the script for the wave queries. I dont think you need that anyway for your game so you can just tick disable queries on the shore mask script.
     
  7. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    Last edited: Apr 29, 2016
  8. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    It's INVERTED... ISN'T IT?

    Edit: tried it with alpha as transparency with full white.. but in either case with the original image I'd have either gotten what i wanted or the opposite.. but I'm not seeing wave suppression anywhere.
     
  9. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    So now I'm seeing this:

    http://imgur.com/FuMnDOK

    In editor, it makes that "normal" noise over the surface, but it's not visible in game *UNLESS* I change my camera to perspective mode, in which case it looks like the editor mode in the screenshot.

    My main cam has to be Ortho. But in either case, it's showing that my map is in the right place and scale, but it does nothing to the height mask as I require.
     
  10. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The white areas are what the mask will affect.

    Ahh, ok. So in perspective mode its working as expected but not in orthographic? It might be a bug with a orthographic camera. I was not expecting anyone to use Ceto in this way. If you can just confirm thats is just the orthographic mode thats the issue then I will have a look at it.
     
  11. mittense

    mittense

    Joined:
    Jul 25, 2013
    Posts:
    168
    When I use this with Amplify Bloom, that effect seems to be getting flipped and I can't figure out why only *that* effect is having that issue. And I've tried the opaque and transparent queue prefabs as well as messing with post effect order on my camera.
     
  12. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi there!

    I'm playing around with CETO, and trying to use this code for a couple of calculations like make splash if the ship is under the water, bullets or stuff like that. I'm using the following code :
    Code (CSharp):
    1. void Update()
    2.     {
    3.         //make splash if enter the water
    4.         float seaHeight = Ocean.Instance.QueryWaves(transform.position.x, transform.position.z);
    5.         if (transform.position.y < seaHeight && !enteredWater)
    6.         {
    7.             enteredWater = true;
    8.             //var splash = Instantiate(waterCollisionFX, transform.position, Quaternion.identity) as GameObject;
    9.             //Destroy(splash, 5f);
    10.             splash.enableEmission = true;
    11.         }
    12.  
    13.         if (enteredWater && transform.position.y > seaHeight)
    14.         {
    15.             enteredWater = false;
    16.             //var splash2 = Instantiate(waterCollisionFX, transform.position, Quaternion.identity) as GameObject;
    17.             //Destroy(splash2, 5f);
    18.             splash.enableEmission = false;
    19.         }
    20.     }
    I'm trying instantiating, and just enabling the particles and i get a drop down of 70 FPS whith both methods. So i asume i'm doing something wrong with the CETO height calculations.

    Any idea of where to start looking at?

    Thanks a lot
     
  13. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The Amplify Bloom effect gets flipped? Ceto enables the depth texture but thats the only thing I can think of that may affect a image effect. That really sounds like something you need to ask the Amplify Bloom publisher.

    You may also want to check if its occurring in both deferred/forward and removing Cetos underwater post effect script to helps narrow down the issue.

    I dont see anything wrong with the code. How many objects are doing this in a frame?
     
    Last edited: Apr 30, 2016
  14. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    It depends. With this code, only one object. The ship. The thing is that the ship is checking it also 4 times more. It is a hover ship with 4 points checking the distance to the water. Without this code i put before it goes at 100 or more fps. With it, can reach 1fps at some points. There is only one ship in the scene, and the ocean is set almost by default, plus one terrain with shore.
     
  15. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I doesn't sound like its ceto wave query that's causing the slow fps. You show be able to call it hundreds of times a frame without much effect on fps.

    I think you need to look in the profiler to see what is causing it.
     
  16. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Thanks @scrawk, but i have unity free. I can't use the profiler. I just can show you the only script running in the scene. Maybe i put something in the wrong place?... Please, Could you take a look at it?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Ceto;
    4.  
    5. public class BASIC_HOVER_CONTROLS : MonoBehaviour {
    6.  
    7.     public float speed = 90f;
    8.     public float turnSpeed = 5f;
    9.  
    10.     public Transform[] thrusters;
    11.     public float ThrusterStrength = 65f;
    12.     public float ThrusterDistance = 5f;
    13.  
    14.     public float dustHeight = 3.5f;
    15.  
    16.     public ParticleSystem dust;
    17.     public ParticleSystem splash;
    18.  
    19.     private float powerInput;
    20.     private float turnInput;
    21.     private Rigidbody rb;
    22.  
    23.     public float rotationAngle;
    24.     public float turnRotationSeekSpeed;
    25.  
    26.     public bool enteredWater = false;
    27.     public GameObject waterCollisionFX;
    28.  
    29.     private float rotationVelocity;
    30.     private float groundAngleVelocity;
    31.     private float seaHeight;
    32.  
    33.     void Awake()
    34.     {
    35.         rb = GetComponent<Rigidbody>();
    36.     }
    37.  
    38.     /*void Update()
    39.     {
    40.         //make splash if enter the water
    41.         float seaHeight = Ocean.Instance.QueryWaves(transform.position.x, transform.position.z);
    42.         if (transform.position.y < seaHeight && !enteredWater)
    43.         {
    44.             enteredWater = true;
    45.             //var splash = Instantiate(waterCollisionFX, transform.position, Quaternion.identity) as GameObject;
    46.             //Destroy(splash, 5f);
    47.             splash.enableEmission = true;
    48.         }
    49.  
    50.         if (enteredWater && transform.position.y > seaHeight)
    51.         {
    52.             enteredWater = false;
    53.             //var splash2 = Instantiate(waterCollisionFX, transform.position, Quaternion.identity) as GameObject;
    54.             //Destroy(splash2, 5f);
    55.             splash.enableEmission = false;
    56.         }
    57.     }*/
    58.  
    59.     void FixedUpdate()
    60.     {
    61.         //hovering
    62.         powerInput = Input.GetAxis("Vertical");
    63.         turnInput = Input.GetAxis("Horizontal");
    64.  
    65.         RaycastHit hit;
    66.        
    67.         foreach ( Transform thruster in thrusters)
    68.         {
    69.             seaHeight = Ocean.Instance.QueryWaves(thruster.position.x, thruster.position.z);
    70.             if (Physics.Raycast(thruster.position, -transform.up, out hit, ThrusterDistance))
    71.             {
    72.                 if (seaHeight < hit.point.y)
    73.                 {
    74.                     float proportionalHeight = 1 - (hit.distance / ThrusterDistance);
    75.                     Vector3 appliedHoverForce = transform.up * proportionalHeight * ThrusterStrength;
    76.                     appliedHoverForce = appliedHoverForce * Time.deltaTime * rb.mass;
    77.                     rb.AddForceAtPosition(appliedHoverForce, thruster.position);
    78.                 }
    79.                 else
    80.                 {
    81.                     float proportionalHeight = 1 - ((thruster.position.y -seaHeight) / ThrusterDistance);
    82.                     Vector3 appliedHoverForce = transform.up * proportionalHeight * ThrusterStrength;
    83.                     appliedHoverForce = appliedHoverForce * Time.deltaTime * rb.mass;
    84.                     rb.AddForceAtPosition(appliedHoverForce, thruster.position);
    85.                 }
    86.             }
    87.             else
    88.             {
    89.                 if(thruster.position.y - seaHeight <= ThrusterDistance)
    90.                 {
    91.  
    92.                     float proportionalHeight = 1 - ((thruster.position.y - seaHeight) / ThrusterDistance);
    93.                     Vector3 appliedHoverForce = transform.up * proportionalHeight * ThrusterStrength;
    94.                     appliedHoverForce = appliedHoverForce * Time.deltaTime * rb.mass;
    95.                     rb.AddForceAtPosition(appliedHoverForce, thruster.position);
    96.                 }
    97.             }
    98.         }
    99.  
    100.         //acceleration
    101.         seaHeight = Ocean.Instance.QueryWaves(transform.position.x, transform.position.z);
    102.        
    103.         if (Physics.Raycast(transform.position,-transform.up ,out hit, ThrusterDistance) || transform.position.y - seaHeight <= ThrusterDistance)
    104.         {
    105.             rb.drag = 1;
    106.  
    107.             Vector3 forwardForce = transform.forward * speed * powerInput;
    108.  
    109.             forwardForce = forwardForce * Time.deltaTime * rb.mass;
    110.  
    111.             rb.AddForce(forwardForce);
    112.  
    113.             if (hit.collider != null)
    114.                 dust.transform.position = hit.point;
    115.             else
    116.                 dust.transform.position = new Vector3(transform.position.x,seaHeight,transform.position.z);
    117.  
    118.             dust.enableEmission = true;
    119.  
    120.         }
    121.         else
    122.         {
    123.             rb.drag = 0f;
    124.             dust.enableEmission = false;
    125.         }
    126.  
    127.  
    128.  
    129.         //rotation
    130.         Vector3 turnTorque = Vector3.up * turnSpeed * turnInput;
    131.         turnTorque = turnTorque * Time.deltaTime * rb.mass;
    132.         rb.AddTorque(turnTorque);
    133.  
    134.         //tilt the ship
    135.         Vector3 newRot = transform.eulerAngles;
    136.         newRot.z = Mathf.SmoothDampAngle(newRot.z, turnInput * -rotationAngle, ref rotationVelocity, turnRotationSeekSpeed);
    137.         transform.eulerAngles = newRot;
    138.  
    139.  
    140.  
    141.  
    142.     }
    143.  
    144.  
    145. }
    146.  
    This is the code of the ship to hover and move around. It goes at 100fps most of the time. If i use the quoted part of code, it drops to 1 as i told you before. I get the same problem if i leave this script with the collision commented and use projectiles. as soon as i get 10 flying around, the ftrames goes down like hell...

    This is the simple bullet script:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Ceto;
    4.  
    5. public class PROJECTILE : MonoBehaviour {
    6.  
    7.     public GameObject waterImpact;
    8.     public GameObject landImpact;
    9.  
    10.     void FixedUpdate()
    11.     {
    12.         /*float seaHeight = Ocean.Instance.QueryWaves(transform.position.x, transform.position.z);
    13.         if(transform.position.y < seaHeight)
    14.         {
    15.             var instImpact = Instantiate(waterImpact, transform.position, Quaternion.identity) as GameObject;
    16.             Destroy(instImpact, 5f);
    17.             Destroy(gameObject);
    18.         }*/
    19.     }
    20.     // Update is called once per frame
    21.     void OnCollisionEnter (Collision col)
    22.     {
    23.         var instImpact = Instantiate(landImpact, col.contacts[0].point, Quaternion.identity) as GameObject;
    24.         Destroy(instImpact, 5f);
    25.         Destroy(gameObject);
    26.     }
    27. }
    I'll use pooling system too, but for now it is just to see how it works. I don't think the instantiating and destroying could cause such a hit in the performance just with 20 objects or so...

    Thanks a lot for your help.
     
  17. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hmm, I did not realize that the profiler was not available in Unity free.

    I suspect the issue is related to the number of object being instantiated.

    This code here...

    Code (CSharp):
    1.    float seaHeight = Ocean.Instance.QueryWaves(transform.position.x, transform.position.z);
    2.         if (transform.position.y < seaHeight && !enteredWater)
    3.         {
    4.             enteredWater = true;
    5.             //var splash = Instantiate(waterCollisionFX, transform.position, Quaternion.identity) as GameObject;
    6.             //Destroy(splash, 5f);
    7.             splash.enableEmission = true;
    8.         }
    When the transform is below the water its going to create a object every 16ms but then only destroy it after 5 seconds. This means you will be creating objects faster than they will be destroy and you could accumulate a lot after only a few seconds. If you have vsync off then you could be creating a new object a lot faster than 16ms.

    Not saying thats the issue but it would be what I would be looking into. I would try and work out how many waterCollisionFX objects are currently created when the fps crashes. If it only a few then maybe thats not the issue but if its hundreds and increasing then that would be a problem.

    If you cant find the issue then if you send me a simple scene I can look in the profiler for you.
     
  18. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Thanks a lot for your help. I'm checking the script step by step to find where is the problem. Let's forget the the projectiles and splash things. If i remove that part and just leave this line of code in the Update function :
    Code (CSharp):
    1. float seaHeight = Ocean.Instance.QueryWaves(transform.position.x, transform.position.z);
    The result is the same. No instantiating is performed... Really weird, because that line is used in hover forces check without problem.

    I'll give a couple of shots more, and let you know. The scene is quite simple, so i can send you the hole project as it is now.

    Thanks a lot!
     
  19. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hey @scrawk ! Sorry again! I don't know what to say... :p I do have profiler... I don't know why i was thinking it was a pro feature only... but anyway it works. You are right, CETO is not the problem here. The particles are. Just enabling the particles dust at the hit point or the wave height it messes all. Now i know where to start working. Thanks a lot for your time and your help.

    Cheers!
     
    scrawk likes this.
  20. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58

    Neither show wave suppression (I want masked areas to be completely flat (like in Stranded Deep). Perspective shows the "normal mask effect" on the projection, but neither show any suppression. Would I see the height mask effect in the editor, or only in game mode?
     
  21. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Just to let all people know, that the huge lag i was suffering with the particles is solved after updating to the latest version of Unity(5.3.4) With the same script and all ceto references and particles runing, there is no more lag at all.

    Thanks anyway for the help. ;)
     
    scrawk and hopeful like this.
  22. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    I've just started to notice a new error:

    IsFinite(outDistanceForSort)
    UnityEngine.Camera:Render()
    Ceto.PlanarReflection:RenderReflectionFor(Camera, Camera, OceanCameraSettings) (at Assets/Ceto/Scripts/Reflections/PlanarReflection.cs:535)
    Ceto.PlanarReflection:RenderReflection(GameObject) (at Assets/Ceto/Scripts/Reflections/PlanarReflection.cs:291)
    Ceto_Ocean:RenderReflection(GameObject) (at Assets/Ceto/Scripts/Ocean/Ocean.cs:1083)
    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)

    It seems to happen whenever my character jumps from one location to another using a teleporter. It doesn't seem to be causing any other problems at the moment, but I'm always a bit concerned when my console fills up with error messages every time I do certain things. Any idea why this is happening, and is there any way to stop it?

    Also, now that you've got caustics working, any word on when it will make it into an update? :)
     
  23. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The mask will only show when running the game but will show in both the game and scene cameras.

    The overlays are definitely not working in orthographic, just checked that, but they should show in perceptive.

    To make the waves flat you will need a mask on both the height mask slot and the normal mask slot.

    If you cant get it to work is it possible to get a simple scene with the issue?

    This sounds like the bug with particles in Unity 5.3. I cant remember if I mentioned it to you before (lost track of who has asked me what) but its cased by Cetos reflection camera rendering particle effects.

    What version of Unity you on? I think the latest 5.3 patches have fixed this.

    The next update is pretty much done and should be out next week.
     
  24. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    I'm giving up on this.. when I added normal mask, and switched to perspective, it added artifacts on top of my game grid that looked way wrong. Not sure what was happening there. It was like wedged shadows, as if someone took a grease pencil and wrote all over. I solved my main issue by turning secularity completely off so it's not as distracting, and that should be fine for my needs. You can still tell that the waves are "between" the grids, but it's not as noticeable with the secularity off.
     
  25. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    Right... I've had so few other problems with particles lately that I didn't even consider the particle effects my teleporters used, and thought it had something to do with the sudden camera movement instead. I'd disabled particle reflections in other scenes by placing them on their own layer, and not rendering it with the reflection camera. As soon as I did that in my new scene the problem went away. :rolleyes:
    PS: I did search this thread for the error I was getting before posting, but it wasn't specifically mentioned earlier. Glad you could make more sense of it than I did. :)
     
  26. sashahush

    sashahush

    Joined:
    Sep 5, 2012
    Posts:
    75
    Can't wait, looks really good!
     
    scrawk likes this.
  27. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Any chance to get the latest beta build? I have a WebGL project that needs it and would rather not muck up the code if a compatible version is coming soon.
     
  28. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The next version is done and will be uploaded today or tomorrow. This ones only a small update. I just need to do the checks to make sure everything is working.

    I can send you the link when thats done.
     
    CaptainMurphy likes this.
  29. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    is there a way to create a good effect if you drop somthing in the water?
     
  30. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    No, not at the moment.
     
  31. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Hey @scrawk how would the waves sync across the network? If I have massive waves and boats, how would I ensure that all clients see the same thing?
     
  32. maxzoech

    maxzoech

    Joined:
    Dec 23, 2013
    Posts:
    23
    Why would you want to do that? It’s just a waste of resources. The game doesn’t need to look EXACTLY the same on all clients.
     
  33. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    had the same issue, we got it to work with this:
    You can use it or base your own script on it, ;)
    i just add this script to my ocean object.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. using Ceto; //1. Add Ceto
    5.  
    6. [RequireComponent(typeof(NetworkView))]
    7. public class NetworkTimeSync : MonoBehaviour, IOceanTime //2. Implement interface
    8. {
    9.     public static NetworkTimeSync instance;
    10.     private float deltaTime;
    11.     public static float time;
    12.     public float netTime;
    13.  
    14.     //How often we sync our time with the servers time, to avoid someone going way off time
    15.     public float syncRate = 3f;
    16.     public float lastUpdate = 0f;
    17.     protected float lastUpdateTime = 0f;
    18.  
    19.     NetworkView networkView;
    20.     void Awake ()
    21.     {
    22.         instance = this;
    23.         deltaTime = -(float)Network.time;
    24.         networkView = this.GetComponent<NetworkView>();
    25.     }
    26.     void Start()
    27.     {
    28.         //3. Add to ocean. Ocean will now call this Now function to get its time.
    29.         if(Ocean.Instance != null)
    30.             Ocean.Instance.OceanTime = this;
    31.     }
    32.     void OnServerInitialized ()
    33.     {
    34.  
    35.  
    36.     }
    37.     void OnConnectedToServer ()
    38.     {
    39.  
    40.         networkView.RPC("GetServerTime",RPCMode.Server);
    41.  
    42.     }
    43.     public float Now { get { return netTime; } }
    44.     void Update()
    45.     {
    46.         time = (float)(Network.time + deltaTime);
    47.         netTime = time;
    48.         if(Network.isClient)
    49.         {
    50.             if(Time.time-syncRate > lastUpdate)
    51.             {
    52.                 networkView.RPC("GetServerTime",RPCMode.Server);
    53.                 lastUpdate = Time.time;
    54.             }
    55.         }
    56.     }
    57.     //server function
    58.     [RPC]
    59.     void GetServerTime(NetworkMessageInfo info)
    60.     {
    61.         networkView.RPC("SetDeltaTime", info.sender, time);
    62.     }
    63.     [RPC]
    64.     void SetDeltaTime (float serverTime, NetworkMessageInfo info)
    65.     {
    66.         deltaTime = (float)((serverTime + (Time.time-lastUpdate)/2) - Network.time);//serverTime - (float)info.timestamp;
    67.         lastUpdateTime = (float)Network.time + deltaTime;
    68.         Debug.Log("NETWORK TIME: " + Network.time + " TIMESTAMP: " + info.timestamp + " Delta " + deltaTime + "  serverTime =  " + serverTime.ToString() + " RealTime: " + (serverTime + (Time.time-lastUpdate)/2) + " DELAY: " + (Time.time-lastUpdate)/2);
    69.     }
    70.     public static float ConvertTimestamp ( double timestamp )
    71.     {
    72.         float timeDifference = (float)(Network.time-timestamp);
    73.         return (NetworkTimeSync.time - timeDifference);
    74.  
    75.     }
    76. }
    77.  
     
    Stormy102 and John-G like this.
  34. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    In the game im making 2 players stand on a small raft that will move on waves, it needt to be almost exacly the same or it will look off, setting it so its in sync is not a waste of resources if you need it.
     
    Stormy102 likes this.
  35. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    @Danirey, you can use the profiler in the personal version of unity 5.* versions, its also free to use
     
    Danirey likes this.
  36. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    :eek: Thanks for that! That's really helpful! Also it's using Unity's old networking system, so even better that I don't have to re-write it. Cheers mate. :)

    Say you are shooting at someone on a boat (Using Battlefield 4 here as an example). If the position of the boat on the client is synced across the network based on the wave position and the server position, averaging it out, then when the client sends their request to the server to shoot, when the server receives this shoot request, it won't be accurate and won't hit the other player, despite the client aiming dead on at them. THAT is why it's not a waste of resources.
     
    imtehQ likes this.
  37. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    Maybe not directly, but can't you query wave heights at a particular position? You should at least be able to add a trigger collider at some median sea level, and have it fire a particle splash effect or whatever when an object hits it. Not as accurate as querying wave heights, but for reasonably calm seas, it might be close enough. Ripples could be a bit harder though. :(
     
  38. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    Yes i was thinking like that maybe add a water height mask there to so it looks like water splash backup, together with a particles but somehow if i create particles when a object hits water the particles always have there rotation messed up. So stuck there to get it working any ideas?
     
  39. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    Looks like the " Buoyancy" Script will incorrect act on water if you use the Medium_64_GPU settings on Spectrum Type on the "Wave Spectrum" script.

    Just a bug i just found out, so i share it :p
     
  40. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    You just need to make sure all the clients are using the same time value. If they are the waves generated will look the same. By default Ceto uses Unitys time value which wont be the same but you can provide a interface for Ceto to get what time is used. The script provided by imtehQ is a good example.

    The key point is to make a script and add the IOceanTime interface. Its then the Now property that Ceo will call to get the time. Its then up to you to make sure this is a value that will be sync to all your clients.

    I was going to mention that method but I thought imtehQ meant if there was a Ceto script to do it. There will be at some point but theres not one at the moment. Maybe even some ripples as well.

    Do you have disable readbacks on the spectrum script tick? Its ticked by default. If ticked the waves will not be read back from them GPU so the buoyancy wont sample them. They will just treat the water as being flat. Reading back the waves from the GPU is dx11 only and very slow so its not something I recommend.
     
    Stormy102 likes this.
  41. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    yea that works, thanks :)
     
  42. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    now i got this issue, the raft moves up and a reflection will show below it while the raft is thiss in the water:


    So you see a shadow, and just below the raft you see a reflection while the Raft could not have it now.
     
  43. JohnRossitter

    JohnRossitter

    Joined:
    Dec 18, 2013
    Posts:
    1,027
    Hi there,
    I'm a fellow asset developer and recently had a customer contact me about some issue with compatibility between our assets. I recently published a pack of post processing shaders, and there seems to be many cases where they don't work together. In some cases my post processing tools seem to completely ignore Ceto. Is the rendering pipeline for Ceto outside of the traditional Unity Deferred pipeline? Are you somehow rendering Ceto after post process shaders?

    Thanks,
    John
     
  44. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The planar reflections work by assuming the ocean is always a flat plane but of course its not. It gets displaced. This means there is going to be a mismatch with the reflections. There not really anything you can do about that, its a limitation of the method used. The only thing you can really do is blur the reflections a bit so its not so obvious.

    Hi John,

    Ceto will always render in forward. The ocean renders in the transparent queue and Unity will always render transparent objects in forward.

    If your image effects use the 'ImageEffectOpaque' tag they will run before transparent objects so will not be applied to the ocean.

    If your image effect runs after the transparent queue then it should be applied to the ocean, however if they effect uses the depth buffer then it wont be applied to the ocean as transparent object dont write into Unitys depth texture (except in deferred dx9 for some strange reason).

    Ceto does include a opaue prefab that will run in the opaque queue so should be affected by images effects that use the 'ImageEffectOpaque' tag. The ocean will still run in forward here however as I use a custom lightning model so Unity will always run it in forward.

    If you need a copy of Ceto to have a look I can send you one.
     
  45. brave_mike

    brave_mike

    Joined:
    May 8, 2013
    Posts:
    26
    Hi Scrawk,

    the poblem with the refelction probes is still there - are there any news solving this issue?
    We need ocean-refections in reflection probes for our project.

    Kind Regards

    Mike

    Ceto-Reflection-Probe-Problem.jpg
     
    Last edited: May 9, 2016
  46. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Sorry Mike but I have not looked into this yet. I had forgotten about it. I will have a look this week.
     
  47. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @Steve Tack : Can you check something for me to see if it fixes the ocean being to bright for you at night. If you go into the OceanShaderHeader.cginc file you will see this on line 12.

    //#define CETO_DISABLE_NO_DIFFUSE_IN_REFLECTION

    Can you uncomment that and see if it helps. You will also need to add a S on the end as it is missing in the current version. like so.

    #define CETO_DISABLE_NO_DIFFUSE_IN_REFLECTIONS

    It might make the reflections a bit darker. You might have to adjust the reflection intensity.

    Also just letting people know I found a few issue with the new version so had to re-submit it today. It means it wont be on the asset store until late next week.
     
    veddycent likes this.
  48. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    232
    Can you make a option to offset the point in the "Ceto/Buoyancy/Buoyancy" script, i like to use it to make items float but i need to add like 4-5 points to each item and a offsite would be nice :)
     
  49. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Sure, I can look into it.

    @John G. : I didnt end up putting in the wind dir offset. I think it maybe best to just offset it before it gets applied to Ceto rather than change Cetos code.

    If your setting the wind dir from a script then just offset it there. I can post a simple script if you like that you can add to the ocean component to offset it for you.

    New version got approved today. Thought it would go to back of queue since I resubmitted it. Guess not. Just a small update to fix a few bugs.

    Ceto Version 1.1.1

    - Fixed a bug where the ocean position offset was not being
    initialized to zero.

    - Fixed a null ref exception when the AddWaveOverlay was added
    during run time.

    - Fixed a issue where the foam was too bright during night.

    - Removed SSS from being applied at night to help reduce
    the brightness of the ocean.

    - Fixed a issue with the grid breaking when underwater
    and looking straight up.

    - The scene view camera will now display the refraction.

    - WebGL now working. Underwater mode must be set
    to USE_OCEAN_DEPTHS_PASS. Other mode is not currently working.

    - Caustics have been added. Their settings can be found
    on the Underwater component. Not currently working for
    USE_OCEAN_DEPTHS_PASS underwater mode and for some
    older versions (5.1.3) of Unity in deferred.

    - Memory allocations have been reduced. This is the lowest
    they are likely to get. Should be 0.3KB to 2.3KB depending
    on settings.

    - There is now a overlay blend mode on the ocean component for
    the height and foam overlay buffers.

    - Fixed a bug where the underwater post effect was flipped in
    forward rendering if multi-sample enabled.
     
    Last edited: May 13, 2016
    veddycent likes this.
  50. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Glad 1.1.1 got approved so quickly by the asset store.

    Looking forward to your next update too.