Search Unity

Ceto (Scrawks Ocean)

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

  1. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    Yes trying to have 0 in the positive z axis. :)
    Tried to change the degree to radian conversion but had no luck, didn't know how to offset the sin/cos uv offsets.

    Edit:
    Just thinking I can add an offset of 90 to the wind direction variable before the conversion.
    If value is over 360 then subtracting 360 from value will bring it back into 0-360 range.
    Will let you know when I get to try it, if it works.
     
    Last edited: Mar 29, 2016
  2. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Worth noting that image effects don't work with single pass stereo (i think) but more pertinent is that currently the only build of unity working with the new Oculus SDK is 5.3.4p1, which doesn't have that feature.
     
  3. The_Geoff

    The_Geoff

    Joined:
    Mar 22, 2014
    Posts:
    7
    I've just noticed that particle systems are not visible underwater unless they are in front of a mesh. I thought they were working previously but I might be mistaken. Is there a known solution or workaround for this?
     
  4. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I think I will have to add in some code to let you choose what axis the wind dir starts at. I can add this next update for you.

    Na, its always been like that.

    Its due to the underwater post effect. It uses the objects depth value to apply the effect but since particles dont render to the depth buffer the effect uses the depth value of what ever is behind them.

    Its a bit of a limitation of the method. You can fix this but it requires writing a custom shader for the particles. I will try and add this to Ceto at some point but have not got around to it yet.
     
    John-G likes this.
  5. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Cool!
     
  6. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    82
    FargleBargle's issue does seem related, so I messed around with that for a while, to no improvement. I'm not using Occlusion Culling, and even tried "reflectCamera.useOcclusionCulling=false;" right before the Render(), to no change. The issue occurs even in the demo scene, whenever the main camera's position.y falls just below 0 (with ocean level set to 0) due to wave action. I suppose that this inverts the projection and causes "weird things to happen", so my hack negates that.

    I'm still developing on Windows 7, so the Single-Pass Stereo Render issues are definitely reproducible there.
     
  7. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    Got it working, was an oversight on my part; :rolleyes:

    For any one that wants to do the change, here is what I did.

    In Ocean.cs at line 145
    Change:
    Code (CSharp):
    1. /// <summary>
    2.         /// The wind direction.
    3.         /// </summary>
    4.         [Range(0.0f, 360.0f)]
    5.         public float windDir = 0.0f;
    6.         public Vector3 WindDirVector { get; private set; }
    To:
    Code (CSharp):
    1. /// <summary>
    2.         /// The wind direction.
    3.         /// </summary>
    4.         [Range(0.0f, 360.0f)]
    5.         public float windDir = 0.0f;
    6.         public Vector3 WindDirVector { get; private set; }
    7.  
    8.         [Range(0.0f, 360.0f)]
    9.         public float windOffset = 0.0f;
    10.  
    11.         [HideInInspector]
    12.         public float newWindDir;
    And from Line 671
    Change:
    Code (CSharp):
    1. /// <summary>
    2.         /// Calculates the wind dir vector
    3.         /// from the wind angle.
    4.         /// </summary>
    5.         public Vector3 CalculateWindDirVector()
    6.         {
    7.             float theta = windDir * Mathf.PI / 180;
    8.             float u = -Mathf.Cos(theta);
    9.             float v = Mathf.Sin(theta);
    10.  
    11.             Vector3 dir = new Vector3(u, 0.0f, v);
    12.             return dir.normalized;
    13.         }
    To:
    Code (CSharp):
    1. /// <summary>
    2.         /// Calculates the wind dir vector
    3.         /// from the wind angle.
    4.         /// </summary>
    5.         public Vector3 CalculateWindDirVector()
    6.         {
    7.             newWindDir = windDir + windOffset;
    8.             if (newWindDir > 360.0f)
    9.                 newWindDir = newWindDir - 360.0f;
    10.             float theta = newWindDir * Mathf.PI / 180;
    11.             float u = -Mathf.Cos(theta);
    12.             float v = Mathf.Sin(theta);
    13.  
    14.             Vector3 dir = new Vector3(u, 0.0f, v);
    15.             return dir.normalized;
    16.         }
    And finally the part I was overlooking: In the wavespectrum.cs script:

    change any reference for the windDir variable to newWindDir and m_ocean.windDir variable to m_ocean.newWindDir
    There should be 18 of them. :)

    Now you should have a new slider in the Ocean Editor that you can create any offset to the ocean from 0-360.
     
    scrawk likes this.
  8. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    If its happens in the demo scene I can normal fix it pretty easily. I had not noticed that. Will have another look. Sound like its not the occlusion culling.

    I looked up the stereo render but I got it confused with stereoscopic render for 3d which is windows 8.1 only.

    Opps. I need to upgrade only way :)

    Will try again. Do I need the Occulus SDK for this? I don't know anything about VR sorry.
     
  9. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    82
    It occurs just before the camera goes underwater, when it's in the trough of a wave, so long as there's something, like the boat in front of the island, visible.

    Crap, it looks like you can't reproduce the VR-mode issue without a VR headset. That's weird, because I tried it with mine disabled before letting you know, so you could repro it, but perhaps something changed in the latest beta (or I'm just losing my mind). However, in looking-over the latest beta release notes, it appears that all Image Effects are currently having issues in this VR mode, so we're both off the hook for now! :)

    (There are some strange reflection artifacts when using Valve's "Open VR" mode, but hopefully that will get taken care of by Unity in coming days as well.)
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    scrawk likes this.
  11. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
  12. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    That's from the GC. The memory allocations seem very high at 11KB. Its normally about 1-4KB.

    Reducing the memory allocations is still on going. I think they have been reduced by about %70 from release and I normally try and reduce them with every update. I will have another look and see if I can remove the rest in the next update.
     
  13. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    This isn't strictly Ceto related, but may be of interest to those that use RTP. I was thinking it'd be cool if Ceto had a caustics underwater effect, then it dawned on my that I'm already using RTP on my test terrains and it has that feature.

    Combined with the Ceto underwater image effect and how Ceto deals with the water surface, it's pretty cool. You can define the water level and at what depth the caustics effect fades out. RTP even comes with a gamma and a linear caustics texture.

    It looks much better in motion, but to give you an idea:
     
  14. sound-and-vision

    sound-and-vision

    Joined:
    Nov 10, 2013
    Posts:
    6
    Probably a good time to learn :)

    I also bought Ceto for use in a VR project. Wanted to add my voice along with kideternal and olavrv. There's probably going to be many more of us soon!

    I think if you were to buy a headset to develop with and were able to add an official "VR supported" logo on Ceto's main Asset Store image, the bump in sales would likely more than cover the cost of the headset.
     
  15. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I get extremely motion sick so I am really not keen on VR but I know its something a lot of people are interested in.

    I have seen people run some sort of VR emulation in the editor with the split screens. Is that a thing or am confusing it with something else? If I can work out how to do that then would that be good enough to test everything is working ok? Or do I need a headset?
     
  16. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    So far the reviews I've read say motion sickness is not a symptom of either the Occulus nor the Vibe, just that the resolution is not as high as a regular monitor. But from what I've read it doesn't seem to give people motion sickness for the most part. Example: (3m10s is the motion sickness part)

     
    scrawk likes this.
  17. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Motion sickness is a result of what you're seeing not matching what your brain is expecting from your inner ear, it doesn't really have anything to do with the headset or resolution. Different people have different reactions. For example, I don't get any kind of motion sickness, not on cars, not on planes, not on roller coasters, not even looking at computer monitors with crazy stuff going on but something about some types of VR games makes me really nauseous within seconds.

    scrawk, you'd probably need a headset. There are some debug outputs but there would be no way for you to see that what you're changing is making a difference or is correct without being able to see the integrated stereoscopic view. It's not a 2D picture, your eyes merge the two images into a 3D image that has real depth.

    However, I wouldn't just go out and buy one just to put some logo on your page yet. Wait for more feedback and find out if it's really necessary. Especially since the only way you'd be able to get one immediately is from somewhere like ebay with a $500+ markup.
     
  18. sound-and-vision

    sound-and-vision

    Joined:
    Nov 10, 2013
    Posts:
    6
    Obsurveyor is right that headsets are hard to acquire / expensive right now, so it would probably make sense to wait a bit.

    The Oculus CV1 (Consumer version 1) is $600 USD + shipping and orders are backlogged till July. The HTC Vive is $800 shipping in May. Scrawk, I see you're in Australia, so I imagine shipping would also add a lot!

    I see that a lot of people are selling thier Oculus DK2's on Ebay (the last development kit released before CV1). This might be a cheaper option especially in another month or so when people start receiving their CV1's and flood the used market with DK2's. Oculus has stated that they will continue to support the DK2 through the remainder of 2016:
    http://www.vrcircle.com/post/oculus-will-support-dk2-thru-2016

    As far as Motion Sickness, that's a complex issue but it largely comes down to movement through the environment. For example, if you're not moving, just standing still and looking around, there's very little chance of feeling ill. Also, if you're in a cockpit type experience, the cockpit helps to pin down your focus, so that you're less affected by the background/environment moving. A lot of third person experiences seem to work well, if you're very careful with the camera movement. This is a really good write up about VR Sickness (and why it's called that instead of Motion Sickness):
    https://forums.oculus.com/community...ty-motion-sickness-vr-simulator-illness-guide

    I know that makes VR sound like it doesn't really work or isn't worth the hassle, but you really have to look at it as a completely new medium, not just a expanded way to experience traditional games. There's a lot of amazing experiences to be had and discovered (and come up with) in VR that just can't be done anywhere else. You just have to work fresh eyes and start from scratch... like the Zen Buddhist's say, with "Beginner's mind".

    There's another more expensive water system on the Asset Store which I bought (and shall not name), that doesn't work in VR. The reflections camera seems to work completely opposite in VR, and you end up with reflections of clouds, sun and objects that move in the inverse direction of the actual objects above the horizon. I went back and forth with the developer and we didn't come up with a solution. Unfortunately that developer didn't have a headset so couldn't reproduce the error. There are also things that just don't work in VR in the way they do in Flat-World (should I trademark that ;) ? For example Normal Maps don't really work. At least they don't show any depth and just look like painted on textures.

    I really love Ceto and want to see it continue to work well in VR. So I guess for now those of us working in VR will do our best to communicate any errors and try to translate solutions between VR and Flat-World.
     
  19. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Thanks @sound-and-vision and @Obsurveyor for the feed back.

    I will diffently continue to support VR and if that means I need to get a head set then I don't have a issue with that.

    On a seperate note the bug some people have reported about the ocean grid breaking when underwater and looking straight up has been fixed and will be in next update.
     
    John-G and sound-and-vision like this.
  20. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    Sounds great! I also see some spike on the wavespectrum script in the profiler, is this related? Is this also possible to reduce?

    Other than this I have to say that Ceto is amazing! Keep up the good work!
     
  21. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Thanks .

    I think it is related. Most of the remaining memory allocation are there.
     
  22. PiotrW

    PiotrW

    Joined:
    Nov 2, 2014
    Posts:
    20
    Hello Peter here.

    I got a question about deferred rendering of Ceto. It is working nice but it has some disadvantages and missing features of deferred rendering options in Unity5.

    Is it possible to render your ocean as it should really be in deferred rendering pipeline with PBR in Unity5?

    Right now probably you use your own way to render it.





    All deferred channels are empty. Nothing is there. Probably depth is saved for ceto ocean because it is working with postprocessors.

    But this way many features is missing.
    Point lights are not working - big feature of deferred rendering - that you can have plenty of them with no big cost.

    With Smoothness and Normal you can use Screen Space Surface Reflection Postprocess. This way you will not need any more planar reflections and twice rendering of the scene. Maybe it can be much faster this way if 3d models are very detailed?

    Would be nice to have it! :)
     
  23. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    For what its worth (probably not that much) I tried Unity SSR with a simple plain to get some sense of what it might be like with an ocean system, and the results were not very good. In particular the visual quality was poor compared to planar reflections on water, and it also seemed to stop working at not very great distances away from the camera. I hope my test was flawed and SSR is still viable option for ocean systems but I now have my doubts about this.
     
  24. PiotrW

    PiotrW

    Joined:
    Nov 2, 2014
    Posts:
    20
    Sure but some sail ships can have thousand of polygons. More of them on scene = more work for CPU/GPU. Plane is not good test point :)

    With SSR it is important to balance it well.
    To achieve good results with SSR probably you need more samples (more calculation as well) and balancing with distance gap between each sample. More normals power you have on surface more diffracted it is.

    It is based mainly on this 5 params -
    • surface smoothness (more smooth is more reflecting),
    • normals - more flat surface reflect more like a mirror
    • number of samples
    • gap between samples
    • distance to check

    Some skies/assets renders for example to sky material which can be probably well reflected on PBR materials.

    Point lights maybe even spotlights are quite cheap in deferred mode according to what I read. Now they do not appear on water.

    I tried it few times. It is possible to adjust it but your planar looks nicer ;)
     
    Last edited: Apr 7, 2016
  25. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Just to clarify, I was using a plane instead of an ocean so that I could actually try SSR reflections. I wasn't using a plane instead of detailed objects like ships that I wanted to be reflected.
     
  26. PiotrW

    PiotrW

    Joined:
    Nov 2, 2014
    Posts:
    20
    BTW they are some problems with your planar reflections on newest Unity3D Beta 5.4.0b12 :) Looks that they are not clearing sometimes when for example I'm rotating camera. I do not have problems before in 5.3. Maybe it is just beta problem
     
  27. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hi,

    Most water systems render in the transparent queue as it makes a lot of the feature you want for water easier to do.

    Problem is that transparent objects always use forward rendering as deferred is not supported. This is why the deferred buffers are empty.

    There is a opaque ocean prefab that will run in the opaque queue where deferred should be supported but the shader does not generate the deferred pass for some reason so runs in forward as well. Not sure why it does that. Nobodies even noticed until now :)

    I dont really recommend using the opaque prefab anyway as its not really the best place to render water.

    As for PBS, unfortunately I did not set the shader up to use Unitys PBR. I just used a custom BRDF lighting model as a lot of my experience with Unity was before Unity had PBR. This was probably a mistake and I might try and change the shaders to use Unitys PBR at some point.

    With SSR since its quite a new feature I dont know to much about it. I know the theroy of how it works but not how Unity has implemented it. If Unity applies the effect after the opaque queue but before the transparent one then I dont think it will be practical to have on the ocean. If they apply it after the transparent one then I might be able to get it working but I will probably have to change the shader to use PBR.

    I had not noticed that the planar reflections are playing up in 5.4. I will look into it.
     
    Last edited: Apr 8, 2016
  28. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I'm still far from being an expert in these matters but I suspect you will run into every hurdle you've thought of there.

    For example looking at the script for Unitys SSR effect, there are lines like the following ones that I have plucked from various parts of the file because I suspect they will probably give you some info about Unitys implementation.

    private RenderTexture m_PreviousDepthBuffer;

    [ImageEffectOpaque]
    public void OnRenderImage(RenderTexture source, RenderTexture destination)

    material.SetTexture("_NormalAndRoughnessTexture", bilateralKeyTexture);

    // Not using deferred shading? Just blit source to destination.
    if (Camera.current.actualRenderingPath != RenderingPath.DeferredShading)
    {
    Graphics.Blit(source, destination);
    return;
    }


    There are other reasons I'd be very happy if you gradually manage to refactor to use PBR and get deferred rendering working, but as per my previous post I'm not convinced the SSR effect is brilliantly suited to, for example, reflecting distant land on a large body of water. I hope I just got some settings wrong and would invite people to setup a scene with Ceto but then switch to deferred and setup Unity SSR effect. Then switch off the Ceto object(s) and replace with a plane at sea level that uses a PBR material with suitable roughness etc settings. Can you get reflections that come anywhere close to the planar camera reflections, or that seem worth the hassle of getting working with Ceto?
     
  29. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Looks like SSR is not supported for transparent objects which is not surprising.

    I also think that SSR would most likely not be suitable for large objects like a ocean but not really sure at the moment. Could just need to tweak the settings. I think it would always be pretty blurry though.

    I probably need to change Cetos shaders to use Unitys built in PBR/BRDF anyway. I think the lighting will look better and it maybe causing other issues that I dont even know about.
     
    John-G likes this.
  30. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  31. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
  32. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That would be great. How high is that on your priority list of things to do? I understand you have other things that you are working on with higher priority.
     
  33. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    New buoyancy is the next feature I will be working on.

    I will be working on new media like demo scenes, screen shots and manual for the asset store for the next few weeks but after that I will start on the buoyancy stuff.

    The method used in that article does look like it could be expensive so I dont know how practical it will be. Just have to try it and find out. I have a voxel method I will also try out which might be faster.
     
    Saevax, Bartolomeus755 and veddycent like this.
  34. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    283
    Great news scrawk, a new buoyancy would be great. Looking forward.
     
    scrawk likes this.
  35. Saevax

    Saevax

    Joined:
    Nov 3, 2012
    Posts:
    58
    Any news on the WebGL version and the flickering that happens underwater when looking up?
     
  36. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The issue with the grid breaking when under water and looking straight up has been fixed.

    Going to look into the WebGL issues in the next few days.
     
  37. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Hopefully it should not be too bad for PC users. Thanks for all your hard work on Ceto.
     
  38. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    Hi,

    Now the different foam layer masks seems to be additive, making the foam overbright in areas where different foam overlap.

    Can you make it so that where for example two foam layers with 0.5 alpha value each overlap, the alpha mask result is still 0,5, and not 1.0?`

    This would be more realistic, and look better.

    Thanks!
     
  39. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    It would look better.

    I will see if I can come up with a better way to blend them.
     
    olavrv likes this.
  40. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Saevax likes this.
  41. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    Here's my current project.. very unconventional use of Ceto but oh my it's so gorgeous.

    Edit: it's target is an 80-inch touch screen laid flat like a table.. those icons on the edges orient the player controls to that person.

     
    scrawk, MarcusWatson and John-G like this.
  42. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    Thanks! We are using your wake system now, and it is working really well! All we need is a more natural blending between different masks, and it will look fantastic!
     
  43. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  44. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
  45. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    After seeing @Steve Tack's post about using RTP's caustics, I've been looking into ways people without RTP can add it. The best I've found so far is the Dual Heights Caustics Generator, which can be used to create tiling animated caustics frames that can be projected onto underwater objects. The only flaw in the whole process is that Unity's orthographic projectors are... weird. I wasn't able to get a projector to cover the whole terrain - it seemed to max out at either 64 or 128 units square, depending on where the projector was positioned, and kept flickering on and off depending on where the player/camera was positioned relative to the projector. I tried setting up an array of tiled projectors, but they didn't work reliably either. I finally got it sort of working by having the projector follow the player around, but that means the caustics move with him rather than in world space as they should. If anyone has a better solution I'd be happy to hear about it (unless @scrawk expects to release his native Ceto version soon :)).
     
  46. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I was going to look at adding caustics soon. I will see if I can get it into the next update.

    The ocean shader calculates the world position of objects under the water from there depth value. I was just going to use the world pos to tile a caustic texture. Same for the under water post effect. That way caustics will be added to anything under the water regardless of where the camera is and it would be pretty much free.

    For the underwater post effect I might have to use the normal so the caustic is only on top of the object but I can switch to using the DepthNormal texture I guess.
     
    FargleBargle likes this.
  47. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    Ya, I figured you already had enough infrastructure there that you wouldn't need to depend on Unity's projectors to do it. Thanks for the update. :)
     
  48. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Though I would add caustics in today since it should not take to long. Turned out pretty good. Still some work to do. They dont move at the moment. Need to work out best way to that. Was just think of distorting the uv based on the wave normal. Also need to add them to the underwater post effect.

    They are only applied to the tops of objects and fade off so you dont get stretching on the sides.

    Best thing is you dont need to do anything. They get added automatically to anything below the water.

    CetoCaustics.jpg
     
  49. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    That looks great! :)

    One problem I had using the projector approach was that I could only see the effect when I was underwater. It was completely invisible from above. Yours looks much better. The projector uses a tiled image sequence as well, leading to a really noticeable tiling grid pattern. I can still see some on the flat area, but it's a lot more subtle. Are you using a texture or generating it procedurally?
     
  50. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Its just a texture I found on the web. Might have a go at a procedural method also. Not sure how practical it would be.
     
    Last edited: Apr 23, 2016