Search Unity

Wanted: Ocean shader

Discussion in 'Works In Progress - Archive' started by bigkahuna, Jan 8, 2009.

  1. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Looks like your version doesn't require Pro, right? That'll make a lot of people happy. Will you be charging for this version? If so, how much? Looks nice by the way, although I'll probably stick to Tore's version (I have Pro and need the underwater capability).
     
  2. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    It will be free. Here is the original license that should be carried to any future release if it contains any materials from these authors, I noticed that the actual distribution did not keept this license, I suppose it is build on a version previous my contribution and Mikko Harjanne (toretank) ?:

    Nicolas Choukroun (aka Nikko), TwinFox and Mikko Harjanne
    Posted originally in a thread at the URL :
    http://forum.unity3d.com/viewtopic.php?t=17621&start=120&postdays=0&postorder=asc&highlight=
    Thanks to all the folks on the Unity3d.com forums.

    Copyright (c) 2009, Nicolas Choukroun (aka Nikko), TwinFox and Mikko Harjanne
    All rights reserved.

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of Nicolas Choukroun (aka Nikko) TwinFox nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     
  3. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    I have noticed that this page: https://github.com/trond/Unity-Community-Ocean didn't retain the original copyrights from the first official public release that was made under this license.:

    Copyright (c) 2009, Nicolas Choukroun (aka Nikko), TwinFox and Mikko Harjanne
    All rights reserved.

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of Nicolas Choukroun (aka Nikko) TwinFox nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     
  4. ToreTank

    ToreTank

    Joined:
    Jun 23, 2008
    Posts:
    165
    The version on Github is solely based on the version from this post: http://forum.unity3d.com/threads/16540-Wanted-Ocean-shader?p=118426&viewfull=1#post118426

    As far as I can see it does not contain any license information, but the readme-file clearly states that it is based on TwinFox' original version. Since this is not based on the version you speak of, there is really no license to preserve, but I suppose a license of some sort should be applied in any case :)

    If it turns out that I am wrong about anything I just wrote, please let me know and I will of course do whatever is required to make it right :)
     
  5. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    ok, anyway, apparently the BSD license cannot be kept because they won't publish anything on the Asset store (even if free) if there is a conflicting license.

    Btw I have worked on an Indie compatible Ocean, that has nothing to do with this Ocean. I thought that people in this thread would be interested in having a look to it.

    The announcement thread is here: http://forum.unity3d.com/threads/83385-Ocean-Shader-for-Indies-%28and-Pro%29

    Video is here, it is better in HD if your internet if fast enough:

     
  6. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    Hi, one question, how can i change the tiles of the ocean? i can see the limits of the see in my boat, what i want its to increase the default ocean (my horizont its so far away). I have tried to increase Tiles_X and Tiles_y but they have a limit and i get always error!!

    Thanks
     
  7. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    @ToreTank: Oupsi, I'm really sorry, I didn't saw your answer and I had other projects to work to now I'm coming back on that problem.

    So for my problem, I'm trying with a Mac Mini 2.26Ghz interl core 2 Duo 2Gb of Ram and an Nvidia Geforce 9400M.

    All my other projects work fine, and the problem with the water is that I can see the undersea without any problem and if I go out of the water It's a fully white or blue screen (not crash) and as I move it change between differents blues and white (Basically the colors of the sea).The GUI are not affected I still can see them and click on them. But no shapes nothing.

    I tried on a friend's recent macbook pro same problem (I haven't got the spec).
     
    Last edited: Mar 29, 2011
  8. ToreTank

    ToreTank

    Joined:
    Jun 23, 2008
    Posts:
    165
    Hmm, this sounds very much like the issue in this post: http://forum.unity3d.com/threads/16540-Wanted-Ocean-shader?p=431728&viewfull=1#post431728

    What version are you using?
     
  9. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    osx 10.6 and Unity 3.3

    I just check your threads and it is exactly the same problem, so I tried the water you gave and this ocean works now on Mac thank's a lot !!

    I'll try aswell the version 4 as soon as it's out.

    Again thank's
     
  10. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    well, now i have other problem... it takes so much triangles, too much polys for my project... do u know how could improve the performance?
    thanks
     
  11. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    I'm making a naval strategy game and the ocean takes so much fps... i need to improve the performance but i don't want to put the ocean bad looking.
    Actually is taking like 25 -30 fps of my game... and that is so much..
    thanks

    @nikko, when is it going to be available??
     
  12. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
  13. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    @bigkahuna, yes the question for nikko must be in his thread, but the rest, its for this ocean...
     
  14. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Try to turn off something like "render underwater relfection/refraction". It makes huge difference.
     
  15. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    hi, one simply thing.
    How can I make the water trail that makes one ship when is in movement?
     
  16. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @konedj - Particles. If you have Pro, you can use a projector + rendertexture to apply it to the water's surface.
     
  17. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    i don't know exactly how could i make it... i have a texture that is going to be the foam, okey, what now?? XD its hard projector and rendertexture :S idk how to start with that,
    Thanks
     
  18. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
  19. makan

    makan

    Joined:
    Jan 8, 2011
    Posts:
    342
    Hey there I'm studying HLSL Shader with Nvidia FX Compressor i might can help
     
  20. phil_ivey

    phil_ivey

    Joined:
    Dec 3, 2010
    Posts:
    31
    not bad....
     
  21. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    are people still working in this project?

    thanks
     
  22. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Using it? Yes. Working on updates to it? Not that I know of (sorry to say).
     
  23. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Does that mean it's just too sweet to change? (^_^)
     
  24. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    :)

    No, it just means that there's only 2 or 3 people that understand the code well enough to change / update it and they're probably busy doing other things.
     
  25. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    bigkahuna thats true, the code is very hard....
    I have been working in a big project since i ask you first about the ocean. It looks really really nice, but the problem is the ammount of fps that it takes....
    I would be perfect one optimization but I know that is very difficult
     
  26. konedj

    konedj

    Joined:
    Dec 7, 2010
    Posts:
    84
    Hello everybody. I was thinking and i might use other water. Why??, because i'm not going to use the waves and this ocean shader is taking a lot of FPS from my game...
    Which water would you recommend me instead of this?? I have seen the pro water but it hasn't too much things to customize...

    Thanks
     
  27. mojojojo

    mojojojo

    Joined:
    Dec 16, 2009
    Posts:
    138
    I've got a box w/ the buoyancy script added but it goes haywire. Anyone know what I can do?
     

    Attached Files:

  28. mojojojo

    mojojojo

    Joined:
    Dec 16, 2009
    Posts:
    138
    Where do you turn of 'render underwater reflection/refraction'?
     
  29. Julien-Lynge

    Julien-Lynge

    Joined:
    Nov 5, 2010
    Posts:
    142
    I just upgraded to the new release of Unity, and the ocean community model is completely crashing Unity when I try to run a scene containing it. I'm not getting any error messages - Unity just freezes for a second or two and then crashes. Disable the gameobject containing the ocean and everything works again.
     
  30. ToreTank

    ToreTank

    Joined:
    Jun 23, 2008
    Posts:
    165
    Is this on OSX? The version I have on my drive (freshly checked out from github) seems to work fine at first try - I'm on Win7.
     
  31. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Works fine on Win 7 64 bit for me as well.
     
  32. immFX

    immFX

    Joined:
    Mar 20, 2010
    Posts:
    110
    After messing with Unity's Water3 for a long, looong time, I'm quite convinced that the community Ocean is far superior than Unity's water in the following features:

    - waves
    - buoyancy behaviour
    - overwater-to-underwater effect
    - underwater look
    - following player/camera

    In contrast, water3 is better in terms of fps (its major advantage actually), shoreline effect, boat wakes (no need of projector) and, last but not least, underwater gradient fog.

    Underwater gradient fog gives a more natural look&feel near coasts and could be a good substitute for the lack of shoreline effect. How difficult would it be to add such an effect to the Ocean shader? Is there a shader guru that would be willing to explain how to do this?

    Here's a pic to make my point clearer:
     
    Last edited: Sep 1, 2011
  33. madpuppy

    madpuppy

    Joined:
    Sep 8, 2011
    Posts:
    2
    could not find the big waves fork :(
     
  34. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I don't think he ever posted it. :(
     
  35. g2mediagroup

    g2mediagroup

    Joined:
    Jun 25, 2011
    Posts:
    98
    Does anyone have a suggestion? I'm looking for the same...I don't want "crappy" looking water, but decent that doesn't take away a lot of fps during game play...

    Preferably near clear and small adjustment to movement...this is for a shallow riverbed terrain.

    Thanks!
    George
     
    Last edited: Sep 14, 2011
  36. omniyo

    omniyo

    Joined:
    Oct 13, 2011
    Posts:
    4
    I have just joined to unity community and i was looking for an ocean shader like this... it looks great, SO great in the videos. But i cannot try it in Unity... because of the update (3.4)... Is there any possibility of running it under this version of unity pro?

    Thanks in advance
     
  37. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    I'm fairly new to Unity, and still sorting some of the features out. After trying all the other water options, including the other ocean water from the wiki, I like the Trond version the best for what I'm doing. It does have a few issues though, and I'm hoping some of the regular posters to this thread can shed some light on them.

    1. The scene I'm working on uses a 1000x1000 unit terrain, starting 100 units below sea level, and extending about 250 units above. Everything looks fine as long as I stay close to sea level, but if I climb up above 200 units or so, I can see what look like the edges of the ocean. The standard water uses a scalable round mesh, so it isn't usually a problem, but this one seems to have corners and it looks ugly. I've tried to mask it with fog, but need way too much before it goes away. I've tried fiddling with the camera clip planes, and adjusting some of the ocean settings, but I'm not sure which is the best for this. The overall scale for the GO doesn't seem to do anything, and the width, scale, and size values for the ocean object in the inspector all seem to refer to the wave animation only. When I try to increase the number of tiles, it gives an error, saying the argument is out of range. I even tried different skyboxes in case that was it, with no luck. Is there a way to increase the overall size of the ocean plane, so that it appears to extend to the horizon, and keep the wave scale and everything else the same? Is there some other factor that might explain these artifacts that I haven't considered? I haven't been able to find any documentation on this at all (except here:)), so maybe there's a simple solution that I just haven't stumbled on yet. Here's a screenshot:



    2. Underwater scenes look great, and completely blow away the island demo, pro water, and water3. The only problem is that I get a flickering white border around my screen whenever I'm under the surface. I'm at a complete loss on this one, and haven't really tried anything yet to fix it. Any suggestions would be appreciated. Another screenshot (I added a black border to make the lines at the edge of the original image easier to see):



    I'm using Unity Pro 3.2 (for backward compatibility with other stuff), running on Windows 7 x64. Any suggestions would be appreciated.
     
  38. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    1. Yup, that's a limitation to Trond's ocean shader. Perhaps Trond will respond with a fix or work around, otherwise you'll need to either scale down the rest of your world or limit camera height .

    2. That was something I started seeing with 3.0. I skipped a few Unity updates due to other issues, but I don't see this anymore with 3.4.1. If I recall correctly, the issue might have been related to how 3.x handled anti aliasing, so try turning that off to see if the issue goes away.
     
  39. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    @bigkahuna: Wow, that was quick. I thought I'd be waiting for days for an answer.

    1. OK, since I want to leave the scene scale and camera height alone, I'm thinking of making a big ring mesh, and placing it around the edge of my scene, just under the normal ocean height. Since all of this happens too far away to see waves anyway, it doesn't need to be dynamic. All I need to do is match the inside color to the ocean surface color, and then fade it into the sky box horizon color. Maybe I'll even attach a color picker script to it so I can tweak it from the inspector. Combined with the fog, it should do the trick. (BTW, I've photoshopped my copy of the default sunset skybox to replace the ugly black parts with a smooth blended horizon fading to dark greenish blue at the bottom. This does get rid of some of the problem, as long as you don't go too high. If anybody wants it, I can post it.)

    2. I'll try fiddling with anti-aliasing, but if 3.4 fixes it, maybe it's time to give it another try. We've been steering clear of it 'till now because it wouldn't run some of our old content, but since a lot of that was based on stuff from the Island Demo, which the new ocean is clearly superior to, maybe we can live without it. I'd like to wait for 3.5 though, since it's so close to release. No point in going through all that pain twice.

    Thanks again for the quick (and useful) response.
     
  40. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    So is everyone having issues with this on 3.4?
     
  41. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    Well, I finally got around to applying the fix for corners on the horizon when viewing from above sea level, and it worked better than expected. I made a big mesh ring, starting at the edge of my terrain, and extending out to where I wanted the horizon to be. I colored it roughly the same as my ocean surface, and placed it about a meter below sea level. I thought blending the colors would be a problem, but the fog covered any differences seamlessly. Since you can't see wave animation at that distance anyway, the illusion of an ocean extending to the horizon is almost perfect. See for yourself:



    @ bigkahuna: Thanks again for the help. Confirming that there was no fix inside the ocean shader saved me a bunch of trial and error, and forced me to think outside the box a bit.
     
  42. mojojojo

    mojojojo

    Joined:
    Dec 16, 2009
    Posts:
    138
    Can anyone tell me the lines of code in Ocean 3.2 that allows the waves to move w/ the camera?

    I'm also looking to see if I can apply the ocean as a script addition to a plane. Does anyone know how to do this. I'm having a host of trouble w/ scaling, and getting buoyancy to work right and was hoping I may be able to just work from a created plane.
     
  43. mojojojo

    mojojojo

    Joined:
    Dec 16, 2009
    Posts:
    138
    What changes need to be made to get it to work w/ indie?
     
  44. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @ungoliath - Look for Niko's ocean water for indie (it's in the asset store) which is a similar project except specifically intended to run with the free version of Unity, this project requires pro.
     
  45. wojtko

    wojtko

    Joined:
    Aug 29, 2010
    Posts:
    2
    I just read all the posts of this forum very very interresting. A nice community effort.

    Certainly because of my poor ability to translate, but I have not found the exact answer to my questions.

    I wanted to redo the scene (see photo).



    If making the ground (or even the lighthouse) is not a problem, I have some issues regarding to reproduce this storm with the ocean and the bursts of water. the camera stays at the same height in a "traveling" rotating 360 °. Not for commercial work - I am an amateur - but to make a greeting card !

    I can not find anything comparable in the forums or in the "applications" ready. Does anyone have the kindness to tell me a tutorial, or better if someone has already done this sort of thing, is it ready to send its assets?

    Thank you very much and forgive me my bad English translation.

    Patrick
     
  46. roto23

    roto23

    Joined:
    Oct 30, 2009
    Posts:
    240
    I couldn't find anything under his name. Does it go by something else?
     
  47. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    I've just discovered a new wrinkle to using the ocean shader (I think). It doesn't seem to play nice with any of the standard water types in Unity, other than basic simple water. If I try to use any of the pro standard waters (daylight water, water 3, water 4), say as pool water on an ocean liner, I get errors saying "Recursive culling with the same camera is not possible" and "Flushing Culler but we havent completed rendering. Are you setting material.shader inside of a Render call?" Not only that, but the error doesn't go away even after deleting the water from the scene. I need to restart Unity to clear it. Has anyone else run into this? If so is there a fix?

    The detailed message for the first error is:

    Recursive culling with the same camera is not possible
    UnityEngine.Camera:Render()
    Ocean:RenderReflectionAndRefraction() (at Assets/Ocean Sources/Ocean.js:953)
    Ocean:OnWillRenderObject() (at Assets/Ocean Sources/Ocean.js:849)
    UnityEngine.Camera:Render()
    Water:OnWillRenderObject() (at Assets/Standard Assets/Water (Pro Only)/Sources/Scripts/Water.cs:119)
    UnityEngine.Camera:RenderWithShader(Shader, String)
    Ocean:RenderReflectionAndRefraction() (at Assets/Ocean Sources/Ocean.js:1072)
    Ocean:OnWillRenderObject() (at Assets/Ocean Sources/Ocean.js:849)

    and it references either lines 953 or 991 of ocean.js on line 3 above.

    The second error has no additional details other than referencing lines 233 and 173 of Culler.cpp.

    The game still builds and runs, but I'm a bit concerned when it's spitting out errors constantly. It can't be good for performance.
     
    Last edited: Jan 6, 2012
  48. yty

    yty

    Joined:
    Aug 10, 2009
    Posts:
    82
    trond Ocean can not support Antialiasing as the post Effect ...
    Who has a good idea?
    I tested the problem is here
    offscreenCam.RenderWithShader (waterBelowShader, "");
    To see the results will affect the Zbuffer result in an error ..
     

    Attached Files:

  49. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    I haven't tried anti-aliasing yet (the ocean shader seems to be resource hungry anyway, without adding any extra post effects), but I'm finding it increasingly difficult to get along with in general, especially since upgrading to Unity 3.5.

    I have one scene that has suddenly started generating a huge number of ocean.js related errors every time I trigger a particular animation. It worked fine in 3.4, but now it doesn't. No idea of the cause. The line numbers mentioned in the initial error messages relate to underwater reflection/refraction, but when I turn these features off, the errors change, and indicate something else. Why the ocean shader should even care about a seemingly unrelated animation sequence is a mystery.

    Some scenes simply refuse to use the ocean shader at all. They don't generate errors, the ocean shader just doesn't run. I add it to the scene, but no water shows up. So far I have no idea what's different in the scenes that work and the ones that don't.

    And it still wants to be the only water in a scene. Adding any of the better native Unity waters to a scene using the ocean shader causes it to break.

    Much as I like the look of the ocean shader, it seems to be not very self contained. It is affected by lots of other possible scene elements, and puts some pretty significant, and hard to predict restrictions on what else you can do in the same scene. It would be nice if there was a fully supported and documented ocean/water shader (and I'm pointing my finger at the native Unity versions as well here) that looked as good as the ocean shader from above and below, and simply worked, without the need for kid gloves and crossed fingers. Until such a thing shows up, I guess I'll keep tearing my hair out trying to figure this one out.
     
  50. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello.

    First of all, a brilliant addon! It's allowed us to make our project much more impressive.

    There's a little problem, though, and I don't think anyone posted it yet (at least with screenshots). When looking up from underwater, there seems to be these artefacts moving along the wavetops. They're in the color of the dirt and they come and go. Seems they're more visible at lower wave heights, so you can only see them in the demo scene if you drop the wave height. Does anyone know what they are and how to fix them or at least make them less distracting?
     

    Attached Files:

    Last edited: Apr 12, 2012