Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

The Community Ocean Shader (Open Source) Unity 5

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

  1. Deleted User

    Deleted User

    Guest

    I am loving this!!..what a hidden gem....Thank you so much!.

    I am trying a very large pacific, see if I can not make it work in my flight sim...found this thread downloaded the repo, created this test in about 15 mins..wow.

    Great work.

    p-
     
    JamesArndt and idurvesh like this.
  2. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Yes, does Buoyancy script scan be used on our custom modular non flat river? It has slopes so Y position of object will always change...is it possible to change Y position in buoyancy dynamically without loosing speed??
     
  3. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    The current script, no. But it could be modified to be used on rivers.
    Unfortunately this is not my priority now, but I promise to try something with rivers and lakes later.
     
    Licarell, hopeful and idurvesh like this.
  4. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Good to see it was easy for you to work with.
    Although the system didn't got much love for flight simulators.

    Some advice I can give you for now:

    Raise the far fog settings.
    Use less tiles (4-6) and raise the Tiles size to 1024 along with the fixed disc setting to on.
    This will work better for higher altitudes and with better performance.
    Lower the choppy scale since as you have it now it produces a lot of foam.
    (The way white caps are produced now, is the old way the system had. A better approach will follow.)
     
  5. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Thanks.
    The buoyancy system, while it works ok, is still hackish.
    It can get a lot better.
     
    hopeful likes this.
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @elias_t : Okay, i try it in other computer the normal for reflection also broken. also with nvidia in this case 750.
    Oh and i use 5.3.1 p2 this time
     
  7. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Ok. Thanks.
    It is important to tell me if you tried it with the 'NATIVE' preprocessor directive disabled in the player settings.

    Also try a WebGL build.


    Ok. Nevermind. I have isolated the issue. I am sure you are using linear color space. I reproduced it here with having linear color space enabled.

    I will investigate why this happens. If anybody can shed some light on it, it would help.

    update: Ok. I found the solution for the linear color space issue. I will update the repo in a few minutes.
     
    Last edited: Jan 11, 2016
    twobob likes this.
  8. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Last edited: Jan 11, 2016
  9. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ah yes i was using linear, sorry completely forgot about this setting since it's always my default and become a habit :p
     
  10. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    If you download the new version you can use linear space now.

    Wait, I uploaded a wrong repo...
     
  11. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    is it up?
     
  12. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    yes now:

    Ok. Here is the linear space fix. (correct now)
    Some textures needed to bypass sRGB to work in Linear Space.


    11/01/20116

    • Linear Color Space fix.
    https://github.com/eliasts/Ocean_Community_Next_Gen/

    edit: reuped again because changing the sea texture settings, made them loose anisotropy. Now they should look better.
     
    Last edited: Jan 11, 2016
    idurvesh and hopeful like this.
  13. Andy3D

    Andy3D

    Joined:
    Jan 31, 2015
    Posts:
    42
    This looks great, keep up the good work guys! Does it / will it support underwater effects? And colour effects around island shorelines, where it goes a lighter colour?
     
  14. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    In the long run, yes.
     
    Andy3D and idurvesh like this.
  15. chientq

    chientq

    Joined:
    Oct 1, 2015
    Posts:
    2
    Can you help me ? I trying ocean in unity and follow step by step for you .
    But I problem need you support for me !
    fps into game demo for me so low ( 30 -- > 50 fps), make game playing see not beautiful (lag)
    thank you for support!
     
  16. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    http://forum.unity3d.com/threads/new-mesh-functions.339490/
     
    elias_t likes this.
  17. elias_t

    elias_t

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

    Please provide more info on what platform and hardware you get these results.

    I would consider this right now to be the fastest ocean system for unity, so running that low is not normal.
     
  18. chientq

    chientq

    Joined:
    Oct 1, 2015
    Posts:
    2
    Hi Elias!
    My system:
    CPU i5 4660
    RAM 8G
    VGA GT730 2G
    Could you detect other reasons for my problems ?
    Thanks! Best.
     
  19. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    On your system it should run super fast cpu wise.

    Your problem might be the very weak graphics card that you have...
    Try to use a faster shader lod (like 4 or 3) or load the mobileFastQ preset to see how it runs.

    edit: a screenshot of your profiler (deep profile enabled), would help.
     
    Last edited: Jan 13, 2016
  20. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    179
    Amazing work! Thank you so much for this. A couple of issues I have are:
    1) Near to the camera I tend to get squares of dark colours. I have played with the settings and can't quite figure it out.
    2) When there is zero wind, the water still seems to be running like there is a fast current. Is there a way to slow this down or do I need to delve into the shaders?
     
  21. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    1. This is a limitation of the SM2 shader for now. It renders the reflection based on per vertex calculations. With the new SM3 shaders this will not be an issue any more.

    2. This comes from the choppiness factor. Zero it out and you will be ok. I see you mean the uv scrolling of the bump maps. Unfortunately there is no parameter now to change the scrolling speed for 2 reasons: a.) On some shader lods the 64 instructions limit for sm2 has been reached. b.) The scrolling uses Sin-Cos Time.

    Find in the shaders lines like this:

    Code (CSharp):
    1. o.buv = float4(o.bumpTexCoord.x + _CosTime.x * 0.2, o.bumpTexCoord.y + _SinTime.x *0.3, o.bumpTexCoord.x + _CosTime.y * 0.04, o.bumpTexCoord.y + o.bumpTexCoord.w );
    And modify them to your needs. But be aware that on some lods you will bypass the 64 instructions limit for sm2.
     
    Last edited: Jan 13, 2016
    hopeful likes this.
  22. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Hi all.

    This is a small Roundup update. I have implemented a radial grid but I took it out, because it didn't perform well and visually was worse then the tile system. I think that I will add as a second option only a projected grid. But i have to see how well this performs too.

    https://github.com/eliasts/Ocean_Community_Next_Gen

    14/01/2016

    • Fixed a bug on runtime loading of ocean presets.
    • Added the variable to define wave density.
    • More documentation in the ocean inspector.
     
    Gherid_lacksGPS likes this.
  23. LucianoAdvenio

    LucianoAdvenio

    Joined:
    May 26, 2015
    Posts:
    4
    Hi elias_t,

    Thank you for this amazing ocean. It fits "almost" perfect in my project.
    I said almost beacuse I can't make the water to receive shadows of a terrain I placed.
    Here is the screenshot. Screenshot.png
     
  24. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Hi. Unfortunately the shaders right now don't support shadows. They will get them though either with an sm2 variation through a 2nd pass or when the sm3 shaders are ready.
     
  25. LucianoAdvenio

    LucianoAdvenio

    Joined:
    May 26, 2015
    Posts:
    4
    Thanks for the reply but you are talking to me in chinese XD I don't know nothing about shaders. Can you recommend a tutorial or a place where I can get started with shaders?
     
  26. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    One of the best sites is this: https://en.wikibooks.org/wiki/Cg_Programming/Unity
     
    idurvesh likes this.
  27. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
  28. LucianoAdvenio

    LucianoAdvenio

    Joined:
    May 26, 2015
    Posts:
    4
    RendCycle and idurvesh like this.
  29. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Thanks much for pointing this out, seems valuable resource....Will look at it soon, my this desktop don't support audio
     
  30. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Cool. I plan to do this also.
    Share your results if you have something.
     
  31. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Alright. I got shadows working.

    Untitled.jpg

    I will post an update when I restructure the shaders and see what can be done with sm2 and sm3 shaders.
    One issue I have, is that when I use the fallback shader as the shadow caster/collector, when shore foam is enabled, all the ocean gets foam... as if the depth buffer is all white.
     
  32. nozprod

    nozprod

    Joined:
    Feb 20, 2014
    Posts:
    5
    Hello guys !

    First great job :)
    Next, is it possible (and what to disable) to use the shader and the generation script without the boyancy system ?
    Actually I'm working on a project which has already its boyancy scripts, I have to update the ocean shader and allow the system to change easily waves level and other parameters linked to the weather.
    I tried to import the script to the project, but I can't make it work properly and the console doesn't display any errors...

    Any help would be great :)
    Thanks !
     
  33. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Hi. You must give more details.
    Also you should keep in mind that the scripts depend on preprocessor directives that are declared in the player settings.
    The main ocean system does not depend on the buoyancy script.
     
  34. nozprod

    nozprod

    Joined:
    Feb 20, 2014
    Posts:
    5
    Well, I'm trying to use the ocean script only to generate the shader (shade, reflection, refraction, foam, etc...).
    In a complete empty project everything is working perfectly, but when I want to import my ocean in an existing project, which already use a dynamic water script, it sucks... I've got a lot of artefacts, screen flickering and other annoying stuff.
    I know it comes from the project and not from your script, but I'm wondering if there's a way to use it as simply as a shader, avoiding any possibly conflict with other scripts. Keeping only the possibility to change the ocean parameters with presets.
    I'm not sur if I'm clear enough, and I'm sorry, I've been working all day long on this and starting to be tired ;)

    Thanks
     
  35. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Well then you might want to investigate the unity4 water pro system and shader.
    This system has become more complicated then just copy the shader somewhere else and expect results.
    This is because the shader and the ocean script interact in various ways.
     
  36. nozprod

    nozprod

    Joined:
    Feb 20, 2014
    Posts:
    5
    Thanks elias.

    Actually I manage to fix my problems, and to adapt the buyoancy script to my scene without losing previous setup.
    It's all good ;)

    Next step for me is to allow the ocean script to be modified in real time from xml files !
    I'll post here when the project will be out. And thanks again for your amazing work !
     
    elias_t and hopeful like this.
  37. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    This is awesome! How can I scale the whole thing down? Standard scaling wont stick...
    thanks!
     
  38. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Use smaller values in the 'Tiles Size' in the inspector.
    Also, reduce the 'Tiles count' slider value.
     
  39. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Thanks! worked great
     
  40. broesby

    broesby

    Joined:
    Oct 14, 2012
    Posts:
    118
    Just wanted to give my applause, kudos and thanks for the amazing work you are doing with this project. I am amazed how fast it is progressing and I promote it where I can ;) ... for instance the Gaia forum (where my attention was brought to it in the first place)... so perhaps all the terrain afficionados will come running.. o_O

    .... I'd love to see the colour changes for lower waterdepths :p
     
  41. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Thanks.

    I have some other obligations right now that will allow me to feed the family.
    Right after I will resolve the depth texture issues that will bring shadow support.
    This will of course allow more effects. Like the depth dependent color.
     
    red2blue, broesby and hopeful like this.
  42. AlenH

    AlenH

    Joined:
    Jun 30, 2015
    Posts:
    42
    Hidden gem! Thanks for so dedicated and out of the box solution Elias!
     
    hopeful likes this.
  43. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    Astounding!
     
  44. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    This is unbelievably gracious of you! What an amazing thing within the Unity community. I'm working on The Defense of St. Augustine and this system will take it where it needs to go.
     
  45. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Thanks guys.

    I have more plans for the system. But it will take some more time due to other obligations.
     
  46. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Yeah I'm really wanting to somehow get the edge blending with terrain working (like the Unity Water4 does). Would this be something I should edit via the shaders or scripts? I'm leaning towards shader, but I don't know how deep your scripts and the shaders are interconnected. I want to experiment adding in depth coloring with a ramp as well.
     
  47. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Right now the shader supports edge blending for shore lines.
    You enable/disable the shader keywords by script or the inspector.

    Script and shader are interconnected mainly through classic updating of shader variables and multicompile keywords.
     
    JamesArndt likes this.
  48. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Ah I see, so I must not be enabling the keyword to blend the edges? I've been messing around with the Shore Distance and Shore Strength properties, but they haven't affect the water's blending with the terrain (only tweaks the foam intensity).

    I'm sort of an idiot when it comes to shaders. What do I need to click or checkbox to turn on edge blending?
     
    Last edited: Feb 6, 2016
  49. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    edit: You should get edge blending. It is probably because:

    a.) the terrain is not writing to the depth buffer.
    b.) the current shader lod does not support shore foam

    The _CameraDepthTexture will be replaced with a depth rendertexture in the future to allow more control over depth rendering for the effects.
     
    Last edited: Feb 6, 2016
    FiveFingers and JamesArndt like this.
  50. majstudio

    majstudio

    Joined:
    Feb 11, 2016
    Posts:
    19
    Very nice project ! I am planning to do a game who will use a lot water physics as a gameplay.
    Does actually your scricpt can be used to "spread" water on a surface, or it's just for static Ocean Rendering, with Boyancy on the top ?
    If not, I will still use your Boyancy script for the Océans of my game, but another particle engine for reactive water. I have to admit your produce great results thought !
    Also, I was wondering how to set up the base project because it seems to have no documentation on GitHub.
    I downloaded all files, I checked them, there is a lot of .meta files, where all those files go to make it work ? Just drop it in Unity ?
    Thank you for your support and keep going !