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

Wanted: Ocean shader

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

  1. nickavv

    nickavv

    Joined:
    Aug 2, 2006
    Posts:
    1,801
    I just tried the latest Ocean shader in not-Pro 2.6, and it looked pretty darn nice. It wasn't transparent though, and I'll be damned if I have the time now to work on that. But it was cool, so good job.

    Also, I had the black edges as well, but turning on fog of a bluish tint killed the problem dead.
     
  2. Necron33

    Necron33

    Joined:
    Oct 30, 2009
    Posts:
    33
    Well, I got them a small bit, I'm currently messing up with Nebula 2 Game Engine, When i have time, I'll be fixing it( Assuming that i can, xD ).
    Thank you for all your thanks!
     
  3. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Did anyone ever find a fix for the tiles not matching up and the join issues?

    For any version?
     
  4. TwinFox

    TwinFox

    Joined:
    Jan 9, 2009
    Posts:
    66
    @Necron33:
    Good work on the visuals, and a big thanks for releasing the modified code! I have not been able to tinker with the script myself as I have been too lazy to hunt the holder of the latest version of the script.

    I made some changes to the code, and now the ocean properly follows the camera with a bearable amount of geometry popping. Unfortunately, I broke the foam code while doing this. It seems that the foam intensity is fixed relative to the tile geometry, but to follow the camera the heightmap now slides across the mesh (hard to explain but quite obvious when looking at the wireframes). Would you mind taking a look at the shader code and see if you could find a solution.

    I also changed the wave height to scale down as the tiles get further from camera. This gives an illusion of a larger ocean, and also greatly reduces the amount of geometry popping. The vertical LOD offset was also increased to better hide the seams between LODs.

    @RHD:
    It is very possible that there was bad UVs and normal vectors across the tile borders in earlier scripts, but I am quite confident that these are fixed in this version.

    Download Ocean v3.3 here
    http://dl.dropbox.com/u/483254/Ocean-v3.3-unity2.6free.unitypackage

    Arrow up/down will move the camera forward and back.
     
  5. Mangopork

    Mangopork

    Joined:
    Aug 16, 2009
    Posts:
    108
    AWESOME guys, Simply AWESOME
     
  6. norby

    norby

    Joined:
    Jul 10, 2006
    Posts:
    277
    Good work TwinFox

    thanks

    Norby
     
  7. Deleted User

    Deleted User

    Guest

    omg, why the hell do i keep getting this error when i try to add it to my project..
    I tried clean project and it works fine there but when i try to add to the project I'm working on atm, this error is produced >.<

    anyone know how to fix it?

    thanks
     
  8. Deleted User

    Deleted User

    Guest

    hello? Anyone know how to fix that error?
     
  9. TwinFox

    TwinFox

    Joined:
    Jan 9, 2009
    Posts:
    66
    Djoscard, did you move the Exocortex_FFT from the Plugins folder? Compilation will fail if you do this, as the Plugins is a special folder.

    If the files haven't been moved, then maybe you could try to manually reimport the plugins folder.
     
  10. Deleted User

    Deleted User

    Guest

    I did not move anything, in fact I cannot even find any plugins folders or the plugin file you mentioned..

    All I do is download that unitypackage, create a new project and when I import the package there it gives this error..
     
  11. TwinFox

    TwinFox

    Joined:
    Jan 9, 2009
    Posts:
    66
    My bad, the Plugins folder was missing from the unitypackage. Grab the v3.2 posted earlier by Necron33, it has the FFT library included, you can import just the Plugins folder.
    I am in the process of fixing the foam I broke earlier, I now know how to do it but I can't promise when I can get it done. I will, however, be more careful when putting the next package together.
     
  12. Necron33

    Necron33

    Joined:
    Oct 30, 2009
    Posts:
    33
    Thanks TwinFox, does any one know when will ocean v4 be released?
     
  13. Mixality_KrankyBoy

    Mixality_KrankyBoy

    Joined:
    Mar 27, 2009
    Posts:
    737
    and where are my waterfalls? ;)
     
  14. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    I'm getting no ocean at all with version Ocean-v3.3-unity2.6free.unitypackage - just a blue background and an unhappy console:
     

    Attached Files:

  15. TwinFox

    TwinFox

    Joined:
    Jan 9, 2009
    Posts:
    66
    Ok, the foam is working again. After running the ocean for a while without the foam effect I really came to appreciate the visual element it adds. A big thanks to whoever originally added it!

    The fixed version can be downloaded here:

    http://dl.dropbox.com/u/483254/Ocean-v3.4-unity2.6free.unitypackage

    There were two Pro effects attached to the camera, Glow and Contrast stretch. Indie users may have to remove these from the main camera.

    I think this project would benefit enormously if it was put to Google Code, Sourceforge or other project hosting site. Anyone here have experience on these sites, especially with Unity projects?
     
  16. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Lovely. :) A couple notes on this package though:

    First, the package is missing "ImageEffects.cs", so anyone trying this will need to add it (from the Pro assets).

    Second, I got a number of compile warnings (see screenshot). It didn't effect the player, but I thought I'd mention it.
     

    Attached Files:

  17. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I've never set up anything like Google Code before, but with all the people contributing now it makes sense to do something like that.
     
  18. Arsonide

    Arsonide

    Joined:
    Nov 16, 2009
    Posts:
    43
    I have also modified the script to work on Indie, and it looks very similar to what Necron came up with so I am betting our solutions were identical, although my ocean is a little more "green".

    http://www.screencast.com/t/YWY1YmNiOT

    Here I cranked up the choppiness to get some foam action going on.

    http://i50.tinypic.com/1xxjdz.jpg

    Right now I'm actually working on getting it to look LESS realistic. My game is more of a stylized type game, almost toony, but not quite. I am loving the shape of the waves, but it's mainly a matter of coloration.
     
  19. Arsonide

    Arsonide

    Joined:
    Nov 16, 2009
    Posts:
    43
    Ok I have effectively stylized the water to my liking:

    Calm Water
    Choppy Water

    However, there are a lot of functions of the water that I no longer use, such as reflection and refraction. I could probably save a lot of computational power by disabling these shader side and script side. I could probably figure out the script, but I don't know a thing about shaders...I just added an outline pass after the main pass for the toon effect, but beyond that I'm clueless. Do any of you know where to start?
     
  20. Slem

    Slem

    Joined:
    Jan 28, 2009
    Posts:
    191
    Anyone still working on this? Would be nice to have a working bouyancy script to follow this. The one in v3 is not very good. HarvesteR, could you post your script with your fix?
     
  21. Mirage

    Mirage

    Joined:
    Jan 13, 2010
    Posts:
    230
    Can we get an upload with the latest versions? I'm not sure who has them, as this is a long thread with multiple contributors. Great work by everyone involved!
     
  22. Arsonide

    Arsonide

    Joined:
    Nov 16, 2009
    Posts:
    43
    Basically the only thing you have to do to make the latest version Indie compatible is go into the script and change the boolean for Reflections and Refractions to be disabled by default instead of enabled. At that point, your water will look like crap skin wise, but be functional shape wise.

    At that point it's just a matter of beautifying it.
     
  23. Necron33

    Necron33

    Joined:
    Oct 30, 2009
    Posts:
    33
    That's why i made my version, because the quality was so bad without pro.

    Here is the link.
     
  24. TwinFox

    TwinFox

    Joined:
    Jan 9, 2009
    Posts:
    66
    I have finally gotten around to creating a project in Google Code for the ocean shader https://code.google.com/p/unity-ocean/. No more guessing where the latest code is!

    To get things started I committed the latest version I had on my computer which was from November last year. Anybody who have worked on the script or shader after this is welcome to commit their changes, although you have to be first added to the project.

    My experience on SVN and google code especially is very limited, so I appreciate any help or hints people can offer in administering the project. Also, I am not 100% sure how an SVN repository will work with unity, but I guess we'll find out soon enough.
     
  25. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Awesome! Amazing how much has been contributed to this project! Thanks!
     
  26. Volcane

    Volcane

    Joined:
    Feb 28, 2010
    Posts:
    4
    This is really good work thanks to all involved.

    I wonder how I go about setting the buoyancy (I am using Necron33's Indie compatible version). Applying the buoyancy script to an object and then setting the ocean into the variable just gives this error:

    NullReferenceException: Object reference not set to an instance of an object
    Boyancy.FixedUpdate () (at Assets\Ocean_v3\scripts\Boyancy.js:48)
     
  27. coalguru

    coalguru

    Joined:
    Feb 13, 2010
    Posts:
    20
    You need to assign ocean object in the buyoance script settings.

    Anyway, the script is far from ideal.

    I feel problem is connected with scale and sizes. Real number, returning from ocean.getwaterheight... is much different from the visual waves size.

    I think the script using that water height and some fixed distance for calculating blobs - which results in non-realistic floating.


    There is some problem with scale in ocean script also - the camera for me is too high at 250m height.
    And putting camera down to 10m over water surface I can not get ocean to look nice , playing with settings.

    Maybe somebody from gurus can comment? Anyway the current ocean is the best realistic from the art way. With a little tuning of textures - on the big screen the video is super meditative.
     
  28. Volcane

    Volcane

    Joined:
    Feb 28, 2010
    Posts:
    4
    I have assigned the ocean I will carry on trying to track what is going on here for me as I am getting a few more errors. But this has a seriously nice look to it and with a bit of tweaking will get make something quite special I am sure.
     
  29. AKSHOBYA

    AKSHOBYA

    Joined:
    Sep 29, 2009
    Posts:
    10
    Hi guys,

    I found a very nice tutorial with a very nice bounyancy behaviour, the problem is, it looks the water is only a plane and will not work with the ocean shader...
    Need to work on it, looks hard to do for me I don't have enough Knowledge to do that...
    But I think the script used for the bouyancy, is very very accurate, used with the ocean it will be definitly amazing....

    The web player :
    http://www.bhsunshine.com/personal/BumperBoats.html
    the project :
    http://www.bhsunshine.com/personal/BumperBoats.zip
     
  30. AKSHOBYA

    AKSHOBYA

    Joined:
    Sep 29, 2009
    Posts:
    10
    Hi guys,

    Thanks a lot for all your works, the ocean looks great !!!

    I would love to improve it until we can get something workable, ifound some differente things I'd to know if we can work on it together...

    - camera infinite is working.
    suppose we have an objectlike a boat we would like to move on the water- how can i do a following camera of my object and still keeping the infinite ocean ? is it alreday workable ? or need to be improved ?

    -Shader looks great but we can do something better, for exemple improve seamless texture scale etc...
    I'm gonna working on this

    -bouyancy : someone manage to fix the scale problem of the script,it could be improve as well for sure

    -wave boat : we need that too !!

    90 pourcent of the work has be done by TwinFox,Nikko, ToreTank, and all other, thanks a lot you are my hero !

    Just the most amazing ocean I've never seen !!!

    100000 thanks !!!

    WE HAVE TO FINISH IT FOR GOD SACK !!!!!

    I'm working on the shader and texture, if someone is ok to work on something else let us know,


    GO GO GO !!!
     
  31. coalguru

    coalguru

    Joined:
    Feb 13, 2010
    Posts:
    20

    Attached Files:

  32. AKSHOBYA

    AKSHOBYA

    Joined:
    Sep 29, 2009
    Posts:
    10
    Very nice !

    That works pretty fine ;)

    your shader ocean looks very nice,

    how did you do exatly ?

    Would you mind share with us your version with the object to check what you've done ?

    Did you have some problem wave scale with the bouyancy ?


    Cheers
     
  33. coalguru

    coalguru

    Joined:
    Feb 13, 2010
    Posts:
    20
    I'd used the 3.4 version of Ocean shader, published few posts earlier here. Added all updates and corrections, discussed in the theme.

    The Ocean.js script (that's important) corrected - Re instead of GetModulus - as it was discussed earlier here. In the buyonce script I just multiplied rigidbody force * 10 (that can be hand-tuned).

    The buoy model is free from turbosquid.

    The scale problem persists - the camera is really at 200 m height. And the buoy is 300 m high also. Total scale of scene is 100x - that is not a big problem.

    I think over now how to generate foam around floating object automatically.
     
  34. AKSHOBYA

    AKSHOBYA

    Joined:
    Sep 29, 2009
    Posts:
    10
    Ok thanks :)

    Which 3.4 ocean did you use ? the nikko's version or the repack for free unity or the repack....
    So many version....

    About the correction youve done there are :

    -ocean.js
    -bouyance.js (can't find it in the last version)

    you're version is working for indie and pro ?

    the foam is not working for me

    bouyance.js mod by harvester ? Page 14
    ocean.js mod by Yann ? page 14

    So many mod of the script, don't know which one was done or not...

    anyway great work ! would love to see foam around the model ;)
     
  35. coalguru

    coalguru

    Joined:
    Feb 13, 2010
    Posts:
    20
  36. AKSHOBYA

    AKSHOBYA

    Joined:
    Sep 29, 2009
    Posts:
    10
    Thanks a lot guru, you're rock !

    :)
     
  37. coalguru

    coalguru

    Joined:
    Feb 13, 2010
    Posts:
    20
    Thanks to the all great guys created mesh generator and shaders.

    - It looks like that concept of ocean is not good for sailable waters. We need seamless mesh tiles to do the trick.

    - Maybe meshes can be not planes but big sphere sectors?

    - Maybe we can put a local foam around colliding objects by the projector, like blob?
     
  38. AKSHOBYA

    AKSHOBYA

    Joined:
    Sep 29, 2009
    Posts:
    10
    the buyouncy script works pretty good, nice,

    few things it looks the windx value does not work with the buyouncy i think I have to let windx<10

    But it's really kool anyway, I try with a boat model and it's working until a certain height of water.

    the buyance is taking i think only one point and the normal orientation...it will be nice to get more accurate floating point to work with a boat shape

    For the tiling ocean with a bit of setting and with a camera not to high and fog properly setup it's working actually pretty good

    for the camera infinite maybe we can infinite the script on the bouyancy objet instead of the camera when the object will move the camera will follow the object...

    My ocean does not look like yours, I have to remove unitypro script to work (glow and contrast)

    I've any reflection of the sky on the shader, the foam is not working, as well don't understand why...

    cheers
     
  39. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
  40. summer006

    summer006

    Joined:
    Feb 16, 2010
    Posts:
    14
    Oh, that effect is amazing...

    can unity do that?
     
  41. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    GREAT WORK GUYS!

    Keep it up it's looking fantastic
     
  42. summer006

    summer006

    Joined:
    Feb 16, 2010
    Posts:
    14
    Hi all,

    I'm new, study Unity3d just few days...
    I found that the water effect in unity package is not very good, and I want a more real one, so I'm here :)

    I checked out this project, and I got some questions, hope some one can help me:

    1, why use several ocean layer and stacked them up? why not use just one large mesh ?

    2, I found the gap between layer and layer, cannot remove it?

    3, I got one old version of this project "ocean", (looks like ver1.0, not sure about that), there are 3 slider on GUI, user can setup some parameter of ocean. And you can go under the water, it looks pretty nice though some bugs exist.....
    But why the new version remove them ?

    4, sometimes, I don't want ocean, but want river, or lake, or swimming pool.....I want stop the wave or change it to tiny one, how do I change the parameter? (I tried a lot, not very good).

    Thank you guys, hope you can help me.
     
  43. coalguru

    coalguru

    Joined:
    Feb 13, 2010
    Posts:
    20
    Ocean is organized by layers by two reasons - to minimize visual holes in geometry due to that animated meshes are not seamless; and to make visual artistic effect of huge ocean with gradient LOD.

    You can switch that off in ocean script, if you want. The GUI sliders are also presented in ocean script - just uncomment their lines.
     
  44. summer006

    summer006

    Joined:
    Feb 16, 2010
    Posts:
    14
    thank you, coalguru, I can understand now. It do is a good way to optimize...looks like the ocean script has done many thing, I gotta study ...
    thanks again. :D
     
  45. MattFS

    MattFS

    Joined:
    Jul 14, 2009
    Posts:
    219
    Hey coalguru - I tried to use this, but there are errors on every ComplexF instant in the JS code. Is there an external library missing?

    Code (csharp):
    1. Ocean.js(174,19): BCE0018: The name 'ComplexF' does not denote a valid type. Did you mean 'System.ComponentModel.ComplexBindingPropertiesAttribute' ?

    Also - regarding endless sailable sea's, how about implementing a projected grid approach? There used to be a great demo + source here - but it has recently been taken down! :(
     
  46. MattFS

    MattFS

    Joined:
    Jul 14, 2009
    Posts:
    219
    ok never mind - I hadn't imported the earlier package!

    So - I'll probably work on the shader for this (something I've usually enjoyed doing!), I've already used the vertex height to lerp between a lighter water color, this already helps sell the appearnace as at waves crests often the water is lighter due to more light through. Also added a more 'refined' fresnel term with a bias and power function.

    ...I noticed the GetWaterHeightAtLocation() is not accurate at all? Is this just a work in progress? Any more luck with it? After taking off all the damping and jsut trying to transform a cube to the 'Water Height' it's still way off... I'm guessing this would be important if you want drift wood or a very bouyant raft to float over the waves... though I'm not sure where to start with this! :)
     

    Attached Files:

  47. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    This is shaping up amazingly; seems the buoyancy script is in need of serious consideration however.

    We're looking to refine it; will post back here once there is something usable.
     
  48. Digitalos

    Digitalos

    Joined:
    Jun 1, 2009
    Posts:
    112
    Just in respects to the wake trails, I found it very challenging to get a decent look, but eventually for our game we've settled on this.

    Controls are WASD + mousewheel for zoom. This is a script on a GO that is a child object of the ship, it makes a mesh at runtime from three points on the ship, with some math to give the crests at the bow, and then I animated the mesh and faded the texture based on speed. If you stop, it transfers the existing mesh trail to a new GO and fades it out and then destroys the GO.

    Pic below:


    We aren't using the ocean shader for our game however, just thought I would share a wake trail solution. :> (P.S. Ignore the fact that it sometimes goes transparent, there are alpha sorting issues in that scene due to a work-in-progress day/night cycle)
     
  49. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Replace the GetWaterHeight function in the Ocean.js script with this:

    Code (csharp):
    1.  
    2. function GetWaterHeightAtLocation (x : float, y : float) {
    3.    x = x / size.x;
    4.    x = (x-Mathf.Floor (x)) * width;
    5.    y = y / size.z;
    6.    y = (y-Mathf.Floor (y)) * height;
    7.  
    8.    return data[width * Mathf.FloorToInt(y) + Mathf.FloorToInt(x)].Re * scale / (width * height);
    9. }
    Should keep things from leaping out of the water ;)

    Just bear in mind that this corrected function does not take into account the choppiness of the waves. So round, smooth waves is the way to go for now ;)

    Cheers
     
  50. DigiForge

    DigiForge

    Joined:
    Mar 31, 2010
    Posts:
    1
    Hey folks :)

    Happened to stumble across this thread via Google while looking for some rather tasty water effects.

    Quite new to Unity (only a few days to be exact) and was wondering if anyone could point me in the direction of how to set this up?

    I've got a basic Island I've created which is surrounded with a body of water, but I'd like the water to be done using the Ocean_V3 package you've created.

    It's all been downloaded and imported into Unity and the folder Ocean_v3 is currently sat within my Project window of Unity but that's about as far as I've gotten so far.

    If anyone could point me in the right direction that'd be awesome and much appreciated, cheers :)