Search Unity

Ocean Renderer

Discussion in 'Works In Progress - Archive' started by scrawk, Feb 24, 2013.

  1. BradHerman

    BradHerman

    Joined:
    Jan 10, 2013
    Posts:
    21
  2. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    If by the vertex shaders you meant the wave forms, they are fantastic but can be a bit brutal on your machine if its not set for gaming, as they're directcompute only thanks to unity restrictions, they're also beasts of things too which are a ton of fun to play with. I cant wait until this is out there and running on everythng, and by there are several ocean models presented during this thread, all of which i can imagine have their uses, the somewhat standard bdrf model he wrote was a great realistic ocean renderer but there was an example of a philips spectrum waveformation as well as my absolute favourite, which is the whitecap 'choppy seas' version which should honestly be learning this guy some money. I posted my beauty shot video of the whitecaps scene earlier in the thread (Although a tad misrepresented cause of hdr fiddling) and i would absolutely love to see this project get a skyshop boost (and maybe even remotivate scrawk into further making these things, he left just as shore effects were coming forth, it was a shame) Easily one of the best things available on unity at no charge

    And thanks for the link on the AC work, i'm quite fond of mucking around in assets i buy and there's a few ocean products coming out that are looking really interesting, and i think i'm going to be kept pretty entertained mixing and matching, realy looking forwards to see what skyshop could do with this however
     
  3. AndyBumpkin

    AndyBumpkin

    Joined:
    Aug 21, 2013
    Posts:
    5
    I just wanted to say that this looks absolutely fantastic! Good work there :D
     
  4. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    lazygunn were you able to make it run on mobile? I just tried the new suimono but it's still very slow and I think he didn't implement your code. I'm about to give up on running any ocean at all on my mobile game, but I've seen it done so it must be possible.
     
  5. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Sorry creat327 there isnt a chance in hell of getting this working on mobile, not a chance, even put through a strong gpu it can be challenging, nevermind relative;y limited handsets

    If youre completely certain you want a realistic ocean on your mobile, in this thread http://forum.unity3d.com/threads/16540-Wanted-Ocean-shader/page40 is a mobile optomised version, but its still very heavy, it allowed me to do this on a samsung galaxy s2 some time ago. The ocean is very controllable, and you can have a storm if you wish



    The shaders in this thread are very demanding, while scrawk went to great lengths to make a cpu based version, the resut left little processing power for much else
     
  6. The_Code

    The_Code

    Joined:
    Jan 9, 2013
    Posts:
    37
    It's great for me, and relativelly optimized :D
     
  7. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    This thread's shaders or the community, and cpu or gpu based?
     
  8. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    @scrawk
    Hi,

    Any news about Proland?
     
  9. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    @lazygunn I think you posted to the version that I helped optimize lol
    Not sure, since there are tons of versions of the community shader and there was no download link on that one, only pics.
    I was hoping for something better. That one is already in my game: www.dogfightplay.com but it has some trouble with scales/sizes the way it is designed.
     
  10. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hi.

    Only started on the code at start of feb but have made good progress. Most of the core profile is done and half of the atmosphere profile.
     
    Last edited: Mar 7, 2014
  11. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Thanks for the reply.
     
  12. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Forgot to ask
    a) Does your works compatible with the original Earth Terrain data (20Gb)
    b) What about the (new) ETA?

    BTW, Until now, your job is free. Some have even been stolen. Honestly, i think you should consider selling this one. :)
     
  13. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    a) There are some technical problems with this so I can not say atm. The data is stored in .dat files as a series of compressed tiiff's and need to be uncompressed at run time. As far as I am aware there is no way to decompress a tiff from a script in Unity ( if anyone knows of a easy way to do this let me know ). There is a tiff decompressor in the dot net framework but it is part of WPF so is not in monodevelop. I am still looking into this. It will most likely require some sort of dll to bypass the issue.

    b) Its hard to say. It depends on how many problem I encounter. Maybe in a few months.

    The original authors where kind enough to provide there code for free. I feel I should only do the same.
    I am porting this for a reason however. I plan on using it as a starting point for my own game.
     
    Last edited: Mar 9, 2014
  14. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    You can leave it free if you want, but you should upload it to the asset store so nobody else can publish it for $.
     
  15. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    @scrawk
    Thank for the reply
     
  16. neopan

    neopan

    Joined:
    Jan 15, 2013
    Posts:
    47
    1 - is there a new earth terrain data?
    2 - is there some advantage to using this over building a world using worldcomposer and terrain composer [using the color map to populate water bodies and roads, etc
    3 - is there some way to import that earth terrain data into unity retaining trees lakes rivers, etc?
    4 - i am working on a virtual earth experiment, allocating 500GB to earth terrain [potentially will use flightgear based streaming terrain etch.. for the experiment thats irrelevant]
    5 - i just found out about this water today.. i want to test by using a simple standard version of it.. are there any places where "polished" free versions are available?
    6 - i plan on giving back whatever i do to the community free, except parts that will eat into my market
     
    Last edited: Mar 23, 2014
  17. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    ZJP was referring to the data used by Proland. Its is just DEM/SMRT data that has been preprocessed a bit.

    ETA - estimated time of arrival.

    If you go to the first page on the first post are all the links the official projects.

    Not unless you write the code to do so your self or find something on the asset store.
     
  18. emorrisgames

    emorrisgames

    Joined:
    Dec 31, 2013
    Posts:
    2
    Is there a way to change the direction of the waves?
     
  19. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    There is nothing in the code to do so. You will have to add it in yourself if you wish to do so.

    Since I am no longer working on this project I am now unsubscribing to the thread. I will no longer be checking on this thread so will not know if any new questions are posted.

    Good luck :)
     
  20. hvalola

    hvalola

    Joined:
    Feb 11, 2014
    Posts:
    1
  21. Gabo_campitelli

    Gabo_campitelli

    Joined:
    Oct 17, 2012
    Posts:
    426
    Hi, i am making a vehicle simulation framework for Unity and for the sea module i am using this ocean to develope. It looks very nice and the possibility of infinite ocean is great for sims. I have a far clip of 90km and it works very good.
    Anyway just wanted to show a quick video of the results
    [video=youtube_share;hR-GavE8NbA]http://youtu.be/hR-GavE8NbA

    If intrested in the Air module http://forum.unity3d.com/threads/233210-Usim-flight-module-in-Asset-Store

    Gabriel.
     
  22. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I made a crude little system with my remix where instead of one spectra, i had three calculated, each at different wind speed, inverse wave age and so on, then i blended between them in the vertex shader hooked to some sliders in the inspector. It's hardly precise or specifically realistic either, but i didn't play with it loong - i guess with some tweaking and experimentation you could get it working well, but that still doesnt account for changes in wind direction - i think as the effect is based around world co-ordinates, it won't rotate as you rotate the grid surface, for some crude wind direction simulation, it could probably be ameliorated easily though, i just haven't thought of it much of late
     
  23. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    That looks nice btw gabo, are you using perlin for the wave shapes?
     
  24. Gabo_campitelli

    Gabo_campitelli

    Joined:
    Oct 17, 2012
    Posts:
    426
    Thank you! No i'm just using the ocean package (the getheights version) as it is. i only have a script to set the size and configurations.
    What i am developing is the ship physics.
     
  25. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Have you found any strong improvement to the getheights version yourself? the boat moves very well so it sems you've spent some good time on it. The problem with the getheights version i find is there's a lack of directionality, and how someone above mentioned, making it quite hard to get a stormy water feel - this along with the very attractive foam generation itself has kept me working on the whitecaps version as it has a 'choppiness' factor giving the waves an edge, but apparently makes getting the heights complicated (i'd imagine because the choppiness effect means vertices are moved laterally as well as vertically) and i havent attempted a solution myself, so it's on hold at the moment as game-viable
     
  26. Gabo_campitelli

    Gabo_campitelli

    Joined:
    Oct 17, 2012
    Posts:
    426
    I use the getheights version unchanged. I use a ocean buoyancy object as reference point to calculate my own buoyancy for the ship's compartments. I use at least 4 points per compartment. So the getHeigth function doesn't need to return other than height at position for my implementation. The buoyancy force diferences at the different buoyancy calculation points makes the resulting force directional. Rough seas have a realistic effect. I also simulate some hidrodynamics for the hull, keel and rudder, as well as drag coefficients.
     
  27. krougeau

    krougeau

    Joined:
    Jul 1, 2012
    Posts:
    455
    Has anyone else tried the Indie version with a Unity terrain? I'm having some issues getting the two to play nice together.
    The ocean itself looks fantastic & I'm really hoping to use it, but it crops up through the lowest points of the terrain and looks pretty odd. Here's a screenshot:

     
  28. krougeau

    krougeau

    Joined:
    Jul 1, 2012
    Posts:
    455
    Doh! Figured it out after a bit of poking and prodding. Nothing complicated, just had to move my existing terrain down below the waves and build up from there. Looks great! Thanks for all your hard work!
     
  29. Deleted User

    Deleted User

    Guest

    This just looks like the old Nvidia tech demo to me and some others look like the proland one? Not complaining as I converted it too and it was a pain in the behind so great work.
     
    Last edited by a moderator: Jun 20, 2014
  30. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    It was the Proland work by Eric Brunetton in the main, if you check Scrawk's blog on this it says much the same
     
  31. Deleted User

    Deleted User

    Guest

    Not got enough time :p :D..
     
  32. Sk8rseth

    Sk8rseth

    Joined:
    Aug 4, 2013
    Posts:
    13
    does anyone know how i would be able to get this water to render at a certain pos.y? instead of the origin. i have a bunch of complex animations built and cannot just drop my terrain lower in order to fix it...

    also is there a version of this that can be used for smaller bodies of water?
     
  33. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I have just added a sea level setting to all the projects so you can set the ocean to what ever y pos you want.

    The projects with the atmospheric scattering also have a horizon level as if you lower the sea level you need to lower the horizon as well to match.

    There is no version for smaller bodies of water.

    The project files should have uploaded in about half hour from now.
     
    Sk8rseth and red2blue like this.
  34. Sk8rseth

    Sk8rseth

    Joined:
    Aug 4, 2013
    Posts:
    13
    thank you Scrawk! amazing job man. really.
     
  35. sadicus

    sadicus

    Joined:
    Jan 28, 2012
    Posts:
    272
    THANK YOU!
     
  36. kaamos

    kaamos

    Joined:
    Aug 6, 2013
    Posts:
    48
    That's some real nice work there lazygunn... how did you get the translucency at the shoreline?
     
    Eric2241 likes this.
  37. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Cheers, i can't recall the shader code atm, it's part of an old suimono 2 beta, but there's a node in Shaderforge that does it, called alpha depth or something
     
  38. kaamos

    kaamos

    Joined:
    Aug 6, 2013
    Posts:
    48
    The node is depth blend, which is used in conjunction with the alpha input of the material. I'm just not quite sure what to do with that concerning this particular shader, particularly since Shaderforge doesn't allow non shaderforge shaders to be opened in it.
     
  39. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Well I can't share the exact shader code as it is not my own but as I will be looking at it later i'll try to give a rough idea
     
  40. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Awesome Scrawk, many thanks. Any ideas on how to avoid those dark areas in my fbx mesh? Or to make them whitish should look awesome alike foam? Thanks

     
  41. Nitrohex

    Nitrohex

    Joined:
    Jan 16, 2013
    Posts:
    58
    Hey Scrawk,

    When i try to use the Ocean prefab in my scene i get:

    NullReferenceException: Object reference not set to an instance of an object
    Ocean.Update () (at Assets/Scripts/Ocean.cs:199)


    and there is no Ocean Grid or Ocean Wireframe Grid objects created as in your project.

    Can you help me solve this?

    Thanks.
     
    Last edited: Sep 24, 2014
  42. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @ Mike4 - Sorry mike, I have no idea what you've done there. All I can say is that all the uniforms for the material are set in the ocean script. If you are using a different mesh and or material make sure all the uniforms are being bound to the material correctly.

    @Nitrohex - The ocean script just wants a reference to a sun object. Just drag any directional light onto the sun variable on the ocean script. On a side note, If you are setting this up in your own project it is unlikely you will want the wireframe overlay. Just delete all reference to the wireframe gameobject in the ocean script. If you dont set the wireframe camera up correctly it will cause the ocean to look washed out. People seem to have trouble with this.
     
  43. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Solved, now any ideas on how to add to the buoyancy script my animated wave mesh? It should behave as being part of the ocean. Thanks.
     
  44. WalterEspinar

    WalterEspinar

    Joined:
    Aug 23, 2011
    Posts:
    84
    Hi Scrawk, the waves don't work properly in unity 5, you can check this?
     
  45. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I dont have Unity 5 so cant really fix it at the moment.

    I will upgrade/fix this project (as well as every other project on my blog) for Unity 5 when I Upgrade.

    I will probably upgrade a few weeks after its release.
     
  46. odival

    odival

    Joined:
    Jun 11, 2014
    Posts:
    57
    @Mike4 , how did you solved the problem with the dark shades in the ocean? Im having the exact same problem. =(
     
    Last edited: Feb 23, 2015
  47. pett-ber

    pett-ber

    Joined:
    Mar 19, 2014
    Posts:
    25
    Hi, im having issues with replacing the Player with the Oculus Rift prefab camera in the BRDF example project. Any suggestions?
     
  48. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Over the next few weeks I will be updating these projects by adding more comments, making the code easier to understand, fixing any code logic that could be done better and other miscellaneous stuff.

    After that is done I will create a separate version of each and upgrade it to Unity 5 and fix whatever has broken if I can.

    I was going to wait until all this was done before adding a comment but I have just updated the Indie version and moved the wave generation onto its own thread.

    Doing so made the frame rate go from 90 fps to 1030 fps on my PC.

    Since this is such a jump in performance I thought I would update that project now instead of waiting a few week before the rest are done.
     
    odival, hippocoder, Paulohmm and 5 others like this.
  49. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    Hey scrawk, I'm trying to understand some basic coding of your projected grid ocean. In Poland project is little complex to read with all the nodes that links together. Since you are updating your projects, I'm wondering that is it possible to implement your projected grid solution from Poland to simple project as "OceanSurfaceEffects" or "OceanBRDF"?

    That will be great help. :)

    Michael
     
    Last edited: Mar 15, 2015
  50. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    :eek: :cool: