Search Unity

The Community Ocean Shader (Open Source) Unity 5

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

  1. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,192
    render textures do not work well on mobile either, just letting you know because I tried it too
    the only solution I've seen working is to actually prebake the texture shores lines into a mesh and degrade the interior part into the water color so it looks natural
     
  2. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Well on most devices that didn't work well I managed to force it with Camera.main.depthTextureMode = DepthTextureMode.Depth;

    But yes some still don't work.

    Unfortunately the solution you are implying while it might look good has its disadvantages ...

    Also look here: http://forum.unity3d.com/threads/depth-texture-not-working-on-some-devices.319568/
     
  3. ItsAmee

    ItsAmee

    Joined:
    Nov 22, 2012
    Posts:
    9
    The hull of the boat under water is drawing white on the OceanShipsWithIsland scene.
    Unity 4.3.3.2 (DX11) - affects PC and PS4.

    Some setting I'm missing or a bug?
     
  4. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    I cannot see the image, but it has to do with the shore line effect, which is about to change due to depth texture issues with android devices.

    You could change the renderque of the boat so it doesn't write to the depth buffer.
     
  5. ItsAmee

    ItsAmee

    Joined:
    Nov 22, 2012
    Posts:
    9
    It's on PC and PS4, not android but I'll look at the render queue, thanks ;)
    transpIssue.jpg
     
  6. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Yes this is not a bug. It is the shore line effect kicking in.

    I will create the depth texture in a render texture with a replacement shader to allow more control on what will get affected by the depth based shore line foam.
     
    RendCycle likes this.
  7. HAWK12HT

    HAWK12HT

    Joined:
    Nov 6, 2012
    Posts:
    26
    This is just great, now only if we can translate this into shader forge :D

    Just tested it with latest update and there are no shadows on water surface using mobile settings.
     
    Last edited: Apr 23, 2016
  8. elias_t

    elias_t

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

    The shadows will come later.
    I wanted to make an update earlier but I am swarmed by some contract jobs and have no time now.

    As soon as I have some free time I will upload an update.
     
  9. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,037
    Always happy to see that someone has a lot of contract jobs! +1 for good paying work. :)
     
    elias_t likes this.
  10. HAWK12HT

    HAWK12HT

    Joined:
    Nov 6, 2012
    Posts:
    26
    Hey elias_t, Thank you :)
     
  11. ItsAmee

    ItsAmee

    Joined:
    Nov 22, 2012
    Posts:
    9
    Shader8 only renders without ShoreFoam fine on PS4.
    With shoreFoam (LOD0) the foam is not drawing as per PC build (Screenshot)

    Some shaders needed .xyz adding to half4s as lerps were expecting half3's eg.
    Code (CSharp):
    1. result.rgb = lerp(_WaterColor.xyz*_FakeUnderwaterColor, _SunColor.rgb*_SurfaceColor*0.85, fresnelTerm*0.65) + clamp(foam.r, 0.0, 1.0)*_SunColor.b + specular*_SunColor.rgb;
    othewise I got compiler errors.

    Any ideas why this is happening? Apart from the shore foam here, the shader looks lovely ;)

    withFoam_PS4.png
     
  12. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Thx for the info on the shader compilation issues.

    On the screenshot I suspect it has to do with the Camera Depth Texture produced.

    This is why I am stating above that the depth should be produced with a render texture and a camera with renderwithshader.

    Look here: http://forum.unity3d.com/threads/depth-texture-not-working-on-some-devices.319568/
     
    Gherid_lacksGPS likes this.
  13. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    250
    Here is a little Feedback of testing with Vive VR:

    Unfortunatly it wasn't going to work.
    When i dropped the steamvr cameraprefab in the scene and hit play Unity was crashing completly.
    Then Unity was allready crashing when i only tryed to open the scene.
    So i don't know the reason, but as of now the Ocean shader and SteamVR do not come along very well.

    (Tested with SteamVR 1.0.8 and not with the last steamVR Build 1.0.9)
     
  14. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    312
    Still wondering about the initial bounce with the floating objects. When going frame by frame when the scene starts, you can see the ocean is flat on the first 2 frames, then on the third it has huge waves and apparently the objects are placed according to this, but on the subsequent frames the ocean is settled to what it actually is supposed to be, and the objects are either floating in the air or submerged before settling.
     
    Last edited: May 17, 2016
  15. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    Is this still supported?
     
  16. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Well... it is not abandoned.

    As I stated many times in previous posts, I have no time right now to make the major update I intend to.
     
  17. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    That's good, but I was wondering if It's possible to use vertex displacement to give a blocky look to the water.

    What I mean is to achieve a look similar to this one: https://www.cryengine.com/community/viewtopic.php?f=310&t=129014 as where he uses vertex displacement to achieve a lego like look. I wanted to know if it's possible to do the same thing, only to give it more of a voxel look?

    https://cdn1.artstation.com/p/asset...ir-carma-08-the-moody-cliffs-1.jpg?1451488515
     
    Last edited: Jun 3, 2016
  18. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Yes, this could be done. I will try this at a later time. But if you want to try it your self, try to modify the shaders.
     
  19. AlexKertis

    AlexKertis

    Joined:
    Aug 28, 2015
    Posts:
    6
    Hi,Elias!
    This asset works great and looks wonderful on its own. Now I'm trying to combine this great looking water with my own wave system and I would like to know what is the best way to modify water mesh after height data has been calculated but before mesh vertices have been assigned. Basically for each mesh vertex I want to add a value coming from my wave aggregator which is calculated for corresponding location in world space. The problem is: I don't clearly understand how to convert a point from data[] array to world space coordinates and vice versa (especially given the fact that there are multiple water tiles). Could you give me some tips about it?

    Now I'm trying to implement this algorithm:
    - Create several pairs of buffer arrays of type ComplexF[] at startup
    - Calculate data[] and t_x[] (do all calculations which occur before calling calcPhase3) each cycle
    - Populate pairs of buffer arrays with modified values from data[] and t_x[]
    - Proceed with original algorithm starting on calcPhase3, but use pairs of buffer arrays when generating meshes affected by wave modifications (how to determine which meshes are affected?)

    Is this a correct way to solve my problem? Or maybe I should approach my problem with a completely different angle?
     
  20. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Hi Alex.

    Yes this is the right way to do things. Do all your modifications before phase3.

    I had already made some research to add some "traquility" map and "local wind" map modifications.

    I see myself updating the system again at August.

    To track which mesh tiles are affected you should determine the tiling factor of your algorithm.
    If you tile your waves on a bigger scale you should alter the waves on the shader level perhaps.

    Also if you do this you should modify the get height functions accordingly.
     
  21. AlexKertis

    AlexKertis

    Joined:
    Aug 28, 2015
    Posts:
    6
    Thanks alot, Elias.
    I've already modified GetHeight methods and have a correct physical behaviour of floating objects when combining waves from multiple sources. Now just need to visualize resulting water surface. I use rather small tile size so I hope modifiying meshes will be enough (as I dont have any experience with shaders).
     
  22. big_rip

    big_rip

    Joined:
    Apr 4, 2016
    Posts:
    4
    What an awesome looking ocean! If only I could use it for my project though. It is not compatible with cubemap reflections (as most water effect are though).
     
    Last edited: Sep 14, 2016
  23. nozprod

    nozprod

    Joined:
    Feb 20, 2014
    Posts:
    5
    Hi folks,

    I've been busy for a while, I managed to fix performances issues, and the project is nearly finished.
    I tried to create some wake effect with a particle system to add more foam when the boat is sailing, but I'm not happy with the result at the moment... And I can't actually make them way better because of webgl restrictions and performances.
    I was wondering if it could be efficient to add some deformation to the ocean to make the wake, with a mesh deformer for instance, or interacting directly with the water physics, and then recreate some decals to make more foam and make it looks like more "wakely". I'm not sure how to do it, and not sure if it will be working on webgl, but I will try. Any advices would be great ;)

    Have a nice day !

    By the way, the project will be out this november, for the Vendée Globe race. I'll post the link of the website in time.
     

    Attached Files:

  24. xp70

    xp70

    Joined:
    Jul 23, 2016
    Posts:
    3
    Hi guys very nice work its amazing
    I looked for set script on specific mesh surface water but its seems just use generated tiles mesh.
    its seems just shader can be use for small surface water.
    Possible set script on specific mesh or add this ability?
     
  25. ATLAS-INTERACTIVE

    ATLAS-INTERACTIVE

    Joined:
    Mar 3, 2014
    Posts:
    1,295
    The 5.4 update seems to have stopped this from displaying properly...
     
  26. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Sorry guys. I have been away and ... still busy.

    I will try to address some of the issues in the next days ...
     
  27. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Hi. I just opened the project on 5.4 without any issues. What have you observed?
     
  28. ATLAS-INTERACTIVE

    ATLAS-INTERACTIVE

    Joined:
    Mar 3, 2014
    Posts:
    1,295
    The first screenshot was before (from one of my builds):
    1.png
    And this is after the update:
    2.png

    As you can see, the surface appears to be almost unlit, receiving very little shading whatsoever.
    These are from the same scene, same lighting, same settings same everything yet the water looks completely different.
     
  29. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    What are your rendering path and color space settings?

    Have the WaterBump and the FoamBump normal textures the bypass sRGB sampling enabled?
     
  30. ATLAS-INTERACTIVE

    ATLAS-INTERACTIVE

    Joined:
    Mar 3, 2014
    Posts:
    1,295
    Rendering Path: Deferred (required for something else)
    Color Space: Linear (required for some shaders)

    These are the same settings used in both images.

    I am unsure of what you mean by:
     
  31. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    For deferred rendering the bypass sRGB sampling on normal maps should be checked on:

    srgb.jpg

    This is unity5.4f3, deferred, linear, dx11.
     
    hopeful likes this.
  32. ATLAS-INTERACTIVE

    ATLAS-INTERACTIVE

    Joined:
    Mar 3, 2014
    Posts:
    1,295
    Ah, that did it.

    When Unity reimported all my assets after the update it had seen fit to set WaterBump back to a Normal Map, so I lost all the Advanced settings.
     
  33. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    283
    I think that this is kinda nooby problem but I can't solve it. The thing is that the reflections are always slightly right from where they should be. How can I fix this?
     
  34. jhuynh_

    jhuynh_

    Joined:
    Sep 2, 2016
    Posts:
    7
    I'm trying to edit the position and scale of the ocean, and I found that commenting out the calculateCenterOffset function allows me to edit it in the ocean.cs script, but when I press play, my settings are reset. Any idea what else I could modify to edit the position and scale?
     
  35. elias_t

    elias_t

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

    If you uncheck the follow checkbox in the Ocean inspector you will be able to move the sea.
    You could also have an empty game object and use this as a target.

    Look in this post also: http://forum.unity3d.com/threads/th...pen-source-unity-5.370818/page-2#post-2443223

    I would not advice to change the scale. This will mess all the metrics up.

    You can change the scale of the ocean spread with the Tiles Size x,z variables (again in the ocean inspector.)
     
    theANMATOR2b likes this.
  36. jhuynh_

    jhuynh_

    Joined:
    Sep 2, 2016
    Posts:
    7
    Thanks for the the response. I unchecked the follow checkbox and that allowed me to move it, but it snaps back to the center of the environment when I hit play again after changing the Position of the ocean. I also tried an empty game object, and moved that to offset the ocean generation, but same issue with it resetting after pressing play.
    I'm trying to make a contained ocean area, that lines up against a shoreline. This ocean looks great, but it looks like waterworld when I can't contain it.
    Thanks for the advice on the scale though, I'll make sure to edit that only in the editor.
     
  37. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Ok. Then do this.

    - Assign a dummy target object for the sea. (set it's postition at 0,0,0)
    - Uncheck Follow.
    - Apply your transformation on the Ocean Gameobject (not on the dummy object) after the game starts. (This is a hack for now.)
     
  38. jhuynh_

    jhuynh_

    Joined:
    Sep 2, 2016
    Posts:
    7
    Thanks for getting back to me! it works thanks :)
     
    Last edited: Sep 13, 2016
  39. big_rip

    big_rip

    Joined:
    Apr 4, 2016
    Posts:
    4
    Does anyone know why refraction and reflection degrade into a complete mess as camera goes lower than about 6 units above water?
    I am trying to drop a first person character into the ocean and despite that the artifacts only last for a few frames, it's still very jarring.
    Is there a way to at least make it less noticeable?
     
  40. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Hi. This is caused by the way the shader handles the reflection. For now it is per vertex based.When it will become per pixel this issue will be gone.
     
  41. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    125
    Is it possible to see the ocean plane when being "underwater"?
     
  42. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    Hi. Not yet. I still haven't got the time to revamp the lib.
     
  43. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    125
    Is there at least some "hack" that would enable this, or am I out of luck with this shader?
     
  44. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    No. There is no hack. It is a matter of implementing an underwater system.
     
  45. 15901519969

    15901519969

    Joined:
    Oct 4, 2016
    Posts:
    1
    Great work~!and mark this when i want to try!
     
  46. mynamepfd

    mynamepfd

    Joined:
    Jan 4, 2016
    Posts:
    15
    顶!效果很棒!刚刚下载了你的代码,还在研究中,希望能多多交流!
     
  47. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    谢谢。更新以后还会来。
     
  48. mynamepfd

    mynamepfd

    Joined:
    Jan 4, 2016
    Posts:
    15
    震惊!你竟然会用中文。其实我能看懂英文,但是就是不会写,所以我一般都直接用中文回复,见谅!
    Amazing!You should speak chinese.Actually I can read english, but can not write,so I often use chinese to reply, execuse me!
     
    Last edited: Oct 8, 2016
  49. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,198
    I just used the google translator :)

    Anyway. I love this project.
    I know I promised to update it a long time ago, but I also have to feed the family.
     
    Last edited: Oct 8, 2016
    Emre_U likes this.
  50. Eknoes

    Eknoes

    Joined:
    Sep 15, 2015
    Posts:
    56
    The shader really looks great, but currently when i click on the ocean object in the editor i get the following error:

    And a warning:
    The inspector looks like this:
    2016-10-15_18-04-56.png

    Any idea whats the problem or how to fix it? I'm using Unity 5.4.1

    Thanks
     
unityunity