Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

The Community Ocean Shader (Open Source) Unity 5

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

  1. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    Great job Elias!!!
    I will download and play with it :)
     
  2. popandersson

    popandersson

    Joined:
    Oct 15, 2015
    Posts:
    6
    Yeh, I meant the mesh of the boat. I have another question though.
    Obviously this is Ocean, but if I want to use it in archipelago the waves are to long. Is there a way to shorten the waves amplitude? It look superb when I see it as ocean waves, but then I have to scale up everything else to unreasonable numbers.
     
  3. popandersson

    popandersson

    Joined:
    Oct 15, 2015
    Posts:
    6
    I figured it out. You really should not answer my questions or more aqurate I should not bother you with stupid questions.
    This is very nice.
     
    elias_t likes this.
  4. Synaps3

    Synaps3

    Joined:
    Mar 31, 2014
    Posts:
    5
    Hey, I asked a question a few weeks ago. I'm having a problem with white lines appearing around objects in front of the ocean. This only occurs with the shore foam turned on. I can't figure out how to fix. Can you please point me in the right direction, or just say you don't know because I don't know if you even saw my question.
     
  5. Synaps3

    Synaps3

    Joined:
    Mar 31, 2014
    Posts:
    5
    I tested by creating a new project in unity and dragging the water prefab onto the scene, along with another object. When I played the scene, the problem still exists (white outline from foam shader). So there is nothing specifically wrong in my main game. I also tried loading the test scene into a new project, the problem persisted. Only when I run the demo scene, inside the demo project itself, there is no problem. It must be one of the settings in the project then, but I can't find it. Disabling anti-aliasing in the fixes the problem in all projects, but that is not a "solution". I checked, and it says anti-aliasing is enabled in the demo project, but the problem does not occur, so there must be some other setting causing the issue.
     
  6. HanYol0

    HanYol0

    Joined:
    Aug 8, 2016
    Posts:
    6
    Im pretty new to game development, or programming in general. thought i would ask here before i waste to much time on this. Is it possible not render the water inside of a floating object? Like having a ship with interior without being flooded with water.
     
  7. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    The fishing boat demo, has an extra deck mesh with a shader that hides the ocean.
     
  8. HanYol0

    HanYol0

    Joined:
    Aug 8, 2016
    Posts:
    6
    Oh sweet, missed that. Thanks.
     
  9. LMUNS

    LMUNS

    Joined:
    Jul 1, 2017
    Posts:
    2
    Hello everyone,
    was just giving the asset a try and loved the results out of the box.

    Now, I am trying to get a good understanding. I will preface by saying I just got into Unity programming and am yet to dabble with shaders.

    1. The Ocean: basically an empty object with the Ocean Script and shader.
    2. Objects are made buoyant using Buoyancy or boyant script

    I have yet to tweak the settings to get an indepth understanding but I was playing around with trying to replace the ocean shader.
    Tried using the one made by przemyslawzaworski

    https://www.shadertoy.com/view/Ms2SD1
    (The latest file and executable present in comments)
    The Repo https://github.com/przemyslawzaworski/Unity3D-CG-programming

    It doesn't work. I am sure it is because of my lack of understanding but was worth giving it a try
     
  10. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    I will take a look at it, but keep in mind that these are some expensive shaders.
     
  11. LMUNS

    LMUNS

    Joined:
    Jul 1, 2017
    Posts:
    2
    Thanks!
    I know I am punching above my weight but I generally try to fiddle around to get a hang of things.
    I appreciate your response.
     
  12. DarkestDay

    DarkestDay

    Joined:
    Feb 2, 2014
    Posts:
    2
    Hi guys, just wanted to notice that this is a great piece of work and I'm in awe of your effort on this project. I guess I could just figure this out by myself, but I appreciate if you could just point me in the right direction with this. I'm trying to use it in civilization-like map as a basic shader for the ocean. I don't need the physics part of it, or underwater effects, just the water movement. So I figured I can just take the shader and material from your repo and use it on my mesh to achieve that, but can't get this to work. It seems I should also use Ocean.cs script, but I think that will drag other dependencies and so on.. So basically what I'm asking is can this be used as just a watersurface shader and what is the minimum I should add to my mesh to achieve that. Or is this simply impossible without using the whole project and your editor component?
     
  13. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,877
    @elias_t was probably talking Less about that and more about the fact that you will be very lucky if you get any realtime game to run those type of fragment based shaders at a good framerate.
     
    elias_t likes this.
  14. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Yes. No point of having the whole project for this simple thing. I will try to make a light project only for plane water.
     
  15. goslappc

    goslappc

    Joined:
    Feb 18, 2017
    Posts:
    2
    @elias_t

    Hello Elias,

    Me and some friends are making a new game using the community shader, but we have run into some problems. We would love to use a mesh collider instead of a box collider, because it will help us stablelize the boat. We are making the game together with the oculus rift.

    We have tried a lot of different solutions, but without any luck. Do you might have any idea on how to enable the usability of a mesh collider, instead of box collider?
     
  16. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hello. Yes it is doable if you modify the buoyancy script.

    There is a simple slicing loop that adds buoyancy blobs to the blobs list: blobs = new List<Vector3> ();

    Modify this to add blobs to a desired hull or mesh.
     
  17. BlueRain01

    BlueRain01

    Joined:
    Aug 22, 2010
    Posts:
    86
    please excuse my ignorance, but i'm kinda confused it which repo should i follow ( and potentially contribute to )
     
  18. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    JamesArndt likes this.
  19. BlueRain01

    BlueRain01

    Joined:
    Aug 22, 2010
    Posts:
    86
  20. hector_plou

    hector_plou

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

    As I said in a previous post, you did a very nice work.

    I've found a problem using mobile phone, there is like a cut between certain planes, there are in a different height.
    Did you realize of this problem?

    I will upload a picture as far as I can :)
     
  21. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    The picture Screenshot_2018-05-03-09-54-44.png
     
  22. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hello. There must be something going wrong with the code that shifts the tiles according to the camera position.
     
  23. hector_plou

    hector_plou

    Joined:
    Dec 7, 2017
    Posts:
    18
    D
    Hi Elias,

    Do you know where should I check or change to solve the problem?
     
  24. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    I'm on it. I will post a solution soon.

    It is the calculateCenterOffset() function.
     
    Last edited: May 3, 2018
  25. TomPo

    TomPo

    Joined:
    Nov 30, 2013
    Posts:
    86
    This is impressive, really ! With such a great performance - I'm stunned.
    Only one little touch is missing - mesh deformation behind the boat for better feeling of foam / wake and some spashes in front and front-sides of the boat.
    Some additional ideas - the faster we go the more and longer foam we are creating, bigger splashes and more deep deformation.
    Also foam should be wider but less visible in time, same for deformation.
    Question - is this also working with 2018.1 with this new HDR shaders ?
     
    Last edited: May 5, 2018
    JamesArndt likes this.
  26. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,912
    This was discussed before. It might be a bit of a bear of a technical challenge. I'm thinking a simpler implementation might be some kind of fading decal that trails the boat. You can have this decal use a transparent normal map and it would look like ripples and a wake (depending on your own custom texture). To solve this problem I'm thinking the first step might be how one would offset the decal to always stay above the ocean surface and underneath the "boat". Maybe even a particle system might be well suited for this purpose, but again my internal question arises: How to keep the particles "aligned" to the surface normals of the ocean surface so it sits offset above it.
     
  27. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,785
    for that the easiest way is to add the ocean deformation to the decal and particles + offset, but that mean you need dense mesh for them. Or you can use a render texture decal of the trails projected into the ocean (screen space or topdown projected)
     
  28. omerselman

    omerselman

    Joined:
    Mar 5, 2016
    Posts:
    20
    Elias is there any tips or tutorials for mobile? I did my best but couldnt increase the FPS over 30. Thanks for the awesome asset btw.
     
  29. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Set the preprocessor directives in player settings: NATIVE;THREADS and it should run faster.
     
  30. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Hi! I've been playing around with the Community Ocean for a couple of days now. It is quite the best water asset I've tried. There are still some issues I've experienced like square trailing shapes sometimes appear at the back of your boat and it is a little challenging to configure a boat with masking to stay above water at all times. If you have very turbulent waves, your boat gets submerged from time to time. So I think it would be better if a boat with a closed-off top design is used. I also still haven't successfully setup a really transparent water and splashing particle effects for my boat.

    Anyhow, I also experienced your problem about the outlines for the player's boat. But when I dragged my boat prefab to the Target field of this Ocean asset, it seem to have disappeared and more water effects like mists and trailing foams emerged. Here is an illustration:



    Thanks to all those folks who contributed to this magnificent water asset! I salute you all! :)
     
    Last edited: May 25, 2018
    elias_t and JamesArndt like this.
  31. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Question: Is there a way to actually make near the surface objects be partially visible with its actual texture slightly muted only instead of just having a white shape as below?

     
    JamesArndt likes this.
  32. hector_plou

    hector_plou

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

    I'm doing my first videgame.
    Could I use the ocean to create the sea?

    Best regards
     
  33. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,912
    ccyr119, elias_t, Johannski and 4 others like this.
  34. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Wow, that is amazing! I hope that will be available as a Unity developer tool soon. :)
     
  35. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,785
    dayuuummm directing wave spectrum, interesting
     
  36. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Was now able to somewhat make near underwater objects partially visible at certain angles by tinkering with the Alpha values of Reflection & Refraction section in the Inspector...



    Also, I think I found out how to fix the "lines" that appear when Cloudmists intersect the water. I just set Render Queue value to "Geometry" and Lightmap Parameters to Default-Medium. It made the Cloudmists less visible... but the lines disappeared.



    One more problem I have now that I can't find a fix is how to hide the moving dark square shape visible behind my boat the first time the game is started. Anybody experienced this and can share some clues/answer?

     
    Last edited: Jun 7, 2018
    JamesArndt likes this.
  37. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Another method I used to reduce the outline is to apply Anti-aliasing to my boat using Unity Post Processing Stack.
     
  38. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,912
    The cloudmist particles can also be resolved by using Deferred rendering path and using a soft fade particle shader. What you are seeing with the mist intersecting the ocean surface is a common problem across a lot of games. It's from particles or shaders that don't have a soft fade where intersections occur. Luckily Unity provides soft fading shaders by default.

    Here is an image of that same issue in an entirely different engine and this image shows the two different shader variations:



    As for the dark square patch, I had mentioned and posted about it a while back. I noticed the same thing. What is going on with that is the calculated foam is not properly crossing over all of the tiles in the same way. What you see there is a corner of a tile that the foam is not blending over onto correctly. I believe one of the developers said that was going to go away as a new foam or tile system would replace it and the issue would be resolved.

    Here is an image I posted a while back about the same tile and foam issue:

     
    RendCycle likes this.
  39. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Thanks for these useful info! :)

    I tried Particles -> Standard Surface -> Fade with "Enable Soft Particles" ticked for the mists. But I noticed in my game, this caused a short stutter just before the mists gets loaded. Thus I might stick with the first method for now. Anyhow, whatever shader settings I used, I experienced a delay of about 50 seconds before cloudmists started appearing.

    Sorry I missed your previous mention about the dark square patch and yup, it goes away but only after I move my boat away to a certain distance. I hope there was a way to actually hide this square patch on game load. Maybe by producing more foams as usual only in the initialization phase of the tile system... But then again, it seems the player must still begin moving away before the square patch can be covered up.

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

     
    Last edited: Jun 8, 2018
    elias_t, JamesArndt and hopeful like this.
  40. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,300
    Wow. This is absolutely great, just downloaded and tested it from the github.

    Please keep it up!
     
    RendCycle and JamesArndt like this.
  41. Kobald-Klaus

    Kobald-Klaus

    Joined:
    Jun 20, 2014
    Posts:
    126
    I am trying to update Ocean into an existing project with an old version of Ocean and run into an issue that was mentioned here 1 year ago:
    when I click the ocean object, the editor does not appear. I get these errors:
    Unexpected top level layout group! Missing GUILayout.EndScrollView/EndVertical/EndHorizontal?
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    UnityEditor.EditorGUIUtility.TempContent (System.String[] texts) (at /Users/builduser/buildslave/unity/build/artifacts/generated/bindings_old/common/Editor/EditorGUIUtilityBindings.gen.cs:325)


    My procedure is:
    move the Ocean and StreamingAssets Folders + the rsp and meta Files from the Downloaded Project Assets Folder into my Assets Folder.
    Then open one of the demo scenes
    The scene works
    Click "Ocean" -> bang - error

    Yes, opening the downloaded project works without errors. But I cannot begin from scratch with my project.
    So how is this editor thingy working. Do I have to register it somewhere in the settings?
    thx
     
  42. Kobald-Klaus

    Kobald-Klaus

    Joined:
    Jun 20, 2014
    Posts:
    126

    I guess I found it: the Assets/Ocean/Editor contents has to go into Assets/Editor
     
    RendCycle likes this.
  43. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Has underwater effects been included already? In case yes, how can it be activated? If no, does anyone have some tips on how to create it?
     
  44. MikeBike

    MikeBike

    Joined:
    Apr 29, 2017
    Posts:
    28
    Played around now I've a white grid over the waves. Disabling grid in gizmo still the same.
    Thanks
     
  45. JamesArndt

    JamesArndt

    Unity Technologies

    Joined:
    Dec 1, 2009
    Posts:
    2,912
    Well my mind is a bit blown by the simplicity of this solution by Ubisoft for Assassins Creed Black Flag. So you know how we all have that problem with the water surface intersecting our ships and the water can be seen through the hull of your ship? Well check out what they did to solve that: deform the ocean around the ship 25 meters down below it! This must only work when your ocean is tessellated enough directly around the ship. Any thoughts or comments on this?

    https://simonschreibt.de/gat/black-flag-waterplane/

    Here is someone else's video of the water displacement occuring, but the ship is not being rendered.

     
    Last edited: Jun 21, 2018
    Mauri, elias_t and RendCycle like this.
  46. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Can we have a screenshot and Unity version?
    Thx.
     
  47. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    @JamesArndt

    Yes this could be done by using higher tessellation and modify the ocean mesh. But an intersection routine with the hull and the ocean should take place.

    A distance field clip shader on a hull could be better perhaps.
     
    JamesArndt likes this.
  48. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Off course. It's free.
     
  49. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hello.

    Yes using NATIVE; SIMD; THREADS as scripting define symbols is recommended (simd will not work on mobile).
    And it is actually much faster.
     
    RendCycle and JamesArndt like this.
  50. Kobald-Klaus

    Kobald-Klaus

    Joined:
    Jun 20, 2014
    Posts:
    126
    I was able to remove that by putting a big underwater square 2000x2000 under the surface.