Ocean Shader for Indies (and Pro)

Discussion in 'Showcase' started by nikko, Mar 27, 2011.

  1. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    I've been working on Ocean and Water since Blitz Basic. I decided to create an Ocean Shader that will work for Indie/Free version of Unity too. Here are some pictures of the result I get. Note: this shader is not a modification of the stock shader or from any other package, it is new and I did it from scratch.
    (better seen in HD of course)


    This shader can be used for any kind of water, here are the features:
    • material on an
    • no repetitive pattern
    • can be used as any shape! (even animated rigidbody)
    • can work from a basic plane primitive, uses almost no polygons
    • underwater, the script switches from one shader to another, also a different skybox with its shader is given for the underwater.
    • caustics (color, strenght)
    • transparency
    • foam (but with no foam texture, the foam is generated by the shader)
    • sun reflection on the water
    • fresnel / refraction
    • faked reflection
    • displacement maps (the map is made from a basic bump map, the animation is generated real time by the shader)
    • color of water, sun, etc.. can be changed from the inspector.

    Attached Files:

    Last edited: Apr 7, 2011
  2. msborat

    msborat

    New Member

    Joined:
    Jun 17, 2010
    Messages:
    89
    Do you going to make a unitypackage of the water to buy
  3. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    yes, working on that, and also I upload a 300MB video to Youtube. It is better to see it animated.
  4. p6r

    p6r

    Member

    Joined:
    Nov 6, 2010
    Messages:
    876
    Fantastic ! (For free version too... Great !!!)

    6R
  5. Frank Oz

    Frank Oz

    New Member

    Joined:
    Oct 13, 2010
    Messages:
    1,564
    Nice work again nikko! You're a regular little asset store powerhouse :)
  6. bigkahuna

    bigkahuna

    New Member

    Joined:
    Apr 30, 2006
    Messages:
    5,419
    Looks nice. Does it include waves besides the bumpmap surface?
  7. megmaltese

    megmaltese

    Member

    Joined:
    Mar 19, 2009
    Messages:
    1,897
    Damn great thing!
    Will it be good also for lakes and rivers?
  8. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    I am not sure to understand. There is no vertex animation. The idea is to fake everything. Typical gaming approach. Everything is done with fresnel/displacement map. So the Ocean is perfectly flat. This is a good and a bad point. The bad point is that of course it is not as impressive as the one in the famous thread you initiated 2 years ago. The good point is that it is more adapted to games and in general the uses of large water plane (industrial presentation etc...), and boyancy is very easy to do. However it would be possible to add the vertex/Ocean animation made by Toretank, but I wanted to do something on my own, so that I can sell it. Also, vertex animation cost a lot in poly, even with LOD. I think this shader can be adapted for iPhone I will do some tests this week.

    Yeah, of course. This shader is designed specifically for large amount of water, lakes and rivers are good. However, there is a good river asset is in the Bootcamp demo... This said, it is water, and very open. Just use different textures and you can do different kind of water. Before I will release in the Asset store I will make presets (refabs) so that you can drag and drop a muddy water, a tropical water etc.. in your project.
  9. bigkahuna

    bigkahuna

    New Member

    Joined:
    Apr 30, 2006
    Messages:
    5,419
    Ok, got it. This looks like it would be perfect for those people who wanted something for iPhones/Android/low spec machines or very large areas for flight sims. Since I'm not doing either of these, I'll likely stick with the "original" ocean shader, but I'm sure your version will do well anyways!
  10. GrimWare

    GrimWare

    New Member

    Joined:
    Jul 23, 2009
    Messages:
    211
    Will this be for free or are you planning on selling it? I still have your other ocean asset from a few months back that I downloaded from your website :)
  11. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    It will not be free :( it is a very different shader from the one from my website. I will release an updated version of the Ocean Shader free, and continue to maintain it for free, as it was a collective effort in the first place.
    However, the free ocean shader is very tricky to use and I doubt it can be used on a game without some work. It is a good technical demo.

    This Water shader is different and answer to a need from the Unity users about having a plug and play water to use for anything, quick and easy.

    I started making water with blitz basic in 2004! Back in time it was without any shader, all on CPU.
    Here are some picture: http://www.nikko3d.com/index.php/old/more-tests-with-water/

    This Ocean for Indie Pro shader represents years of experience in trying to get the most realistic water from nothing. If I sell some, it will be finally something I get back from all this work done before.

    And btw, here is an image of this water on a lake...that's for @megmaltese
    Of course no special Fx in these pics.

    Attached Files:

    Last edited: Apr 7, 2011
  12. angel_m

    angel_m

    Member

    Joined:
    Nov 4, 2005
    Messages:
    847
    How is the performance of your water-ocean shader compared to the new water3 from Unity 3.2 and the standard pro water shader (Unity) ?
    Is it possible to implement real reflection ( for Pro)?
    I ask this because I need a very large ocean and the water3 shader performance is not good enough for me. I like your water better than the standard pro water so I am very interested in using your shader.
    By the way I remember your water project from Blitz forums. :)
  13. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    This shader is almost invisible on the CPU because it is all in the frag/vertex shader. It is a classic shader (not a surface shader 'made in Unity'). The fragment shader takes 64 instruction, and that's it. I don't think it uses more resources than a 2 or 3 bump mappings.
    Actually there is some work on the CPU too, I increment some variable and copy the Inspector variables in the shader so that you can tweak the parameters live.
    2 textures are animated. The caustics, and the main diffuse texture is in fact a list of 8 textures looping but with fading (the textures are fading from one to another). It is a trick so that the light seems to pass thru the waves and the water get darker/lighter according to the normals position.
    The Displacement map calculation is made in the Shader and uses 2 cos moving together in order to circle the normals at different speed, that's also how you can move the water in one direction for example. The cos calculation is done on the CPU and sent to the shader.
    It is a LOT faster than the free Ocean shader, on my laptop I get around 50FPS with the free ocean shader and about 300FPS with this shader..

    About reflection it is very easy, I will probably do it at one point.

    Btw another demo:
    .
    Last edited: Mar 28, 2011
  14. NomadKing

    NomadKing

    Member

    Joined:
    Feb 11, 2010
    Messages:
    977
    Very nice looking water nikko :)
  15. afalk

    afalk

    New Member

    Joined:
    Jun 21, 2010
    Messages:
    165
    Looks fantastic! I'll keep an eye out for its release in the Asset store!
  16. bigkahuna

    bigkahuna

    New Member

    Joined:
    Apr 30, 2006
    Messages:
    5,419
    In that video, your water looks a lot like the original Pro water (except it doesn't need Pro and it sounds like it has a lot less overhead).
  17. creat327

    creat327

    Member

    Joined:
    Mar 19, 2009
    Messages:
    483
    just curious, have you tested it on iphone/android? i would love to use this for my iphone/android game but I'm curious about the speed. I haven't been able to use any of the water included with the standard library, they are all too slow or ugly for the mobile.
  18. grfxman

    grfxman

    New Member

    Joined:
    May 28, 2009
    Messages:
    309
    As long as this is compatible with Unisky plugin I would buy it in a heartbeat. Looks great :) If it had foam on waves and beaches it could be a total water replacement system for Unity.
  19. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    I own Unisky, I will test, also if the author of the boyancy pack could contact me in private I would like to test his pack?
    I still need to fix an artifact with the sun reflection, and I will release maybe tomorrow.
  20. sebako

    sebako

    New Member

    Joined:
    Jun 27, 2009
    Messages:
    295
    can't wait for the release! :) Keep it up
    any ideas for a price yet?
    Last edited: Mar 30, 2011
  21. GrimWare

    GrimWare

    New Member

    Joined:
    Jul 23, 2009
    Messages:
    211
  22. grfxman

    grfxman

    New Member

    Joined:
    May 28, 2009
    Messages:
    309
    So is this Shader 2 compatible or is it shader 3
  23. angel_m

    angel_m

    Member

    Joined:
    Nov 4, 2005
    Messages:
    847
    Please, add an option for true reflection...
  24. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    I spent 10 min to integrate the water into Unisky. Drag and drop and charge 2-3 things. I will make a video just in case.
    Unisky is weird, its demo scene is located at y=-45000 hu?
    Also I cannot stop the rain when it start to fall, if someone tell me how to do it.
    Bottom line, it is working, the sun reflections are following the Unisky sun with no modification.

    If you notice the water does not look the same in the 2 pictures. Actually I change the normal map. I have 5 normal maps and for quiet water I use NormalOcean, in the second picture I use Busywater.

    @Grfxman: this shader can work for shader 2.

    @angel_m: this is the version for Indie. I will upgrade it for PRO after. True reflection is easy. I just have to replace the fake picture with a camera grabbed cubemap

    Attached Files:

    Last edited: Apr 3, 2011
  25. grfxman

    grfxman

    New Member

    Joined:
    May 28, 2009
    Messages:
    309
    When you add the Unisky prefab there is an option to set which camera it follows just drag your camera and drop it in the slot. Also if you have the latest one there are a couple of shaders you need to add to your camera as well. The unisky follows your camera at runtime after you have it set up.

    The weather tab controls how often it rains 0 is usually forever in their settings. It a little touchy so you will have to play with the settings a bit to get what you want.
  26. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    Works, I also tested with the Buoyancy Pack from Gustav Olsson, and it works perfect too.
    I am working on the editor now.

    Attached Files:

  27. creat327

    creat327

    Member

    Joined:
    Mar 19, 2009
    Messages:
    483
    Nikko, I like how it looks but you haven't replied my post... does it work with iphone/android?
    Is it shader1, 2, 3?
  28. grfxman

    grfxman

    New Member

    Joined:
    May 28, 2009
    Messages:
    309
    I was looking at your last picture and thought I would mention that the water would probably be on Several poly planes in an advanced game. Each with different settings. Rivers and lakes would be very different coloration then the oceans. In my case the diferent set-up would be because I am do a large streaming terrain set-up.
  29. afalk

    afalk

    New Member

    Joined:
    Jun 21, 2010
    Messages:
    165
    Looks amazing! I keep checking the asset store for this one.
    Last edited: Apr 3, 2011
  30. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    I didn't tested it on iPhone, iPad... I will need to do a specific version for these platforms. I have iPhone Pro so I will do it.

    @grfxman: you can set the size of the plane, and have several ones. Yes I agree, water must be different for each so I am working on some sort of 'save' function that creates a prefab on the fly when you get the preset you want in the editor. After you can just use that prefab inside the game. I will give about 6 prefabs in the 1st release, lake, ocean, tropical, busy, quiet and river.
  31. HarvesteR

    HarvesteR

    Member

    Joined:
    May 22, 2009
    Messages:
    418
    Hey this looks mighty good!! great job!

    Will it work on a non-XZ-aligned water surface (i.e. a sphere or sphere section)?

    I'm looking all over for a water shader that doesn't need to be XZ aligned... apparently everyone thinks game worlds should be flat... ;)

    Cheers
  32. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    Hey good idea, I tested and it works for half sphere. For some reason the bottom gets distorded. Should not be hard to fix though.
    I tested on a torus and different shape, and the top is doing good, the only problem is for everything located under y=0. Also underwater may be more complicated to do. (check the pictures attached)

    Ah, a tutorial video, with my French accent as always! The pack is almost ready.

    Attached Files:

    Last edited: Apr 6, 2011
  33. norby

    norby

    Member

    Joined:
    Jul 10, 2006
    Messages:
    204
    Hi Nikko

    This looks amazing , will you have shoreline detection in the Future?

    Thanks

    norby
  34. bigkahuna

    bigkahuna

    New Member

    Joined:
    Apr 30, 2006
    Messages:
    5,419
    That sphere looks pretty darn cool! :)
  35. PrimeDerektive

    PrimeDerektive

    Member

    Joined:
    Dec 13, 2009
    Messages:
    2,959
    Do you think you'd be able to tweak it to make an indie-friendly heat distortion effect?
  36. Fishman92

    Fishman92

    Member

    Joined:
    Feb 9, 2010
    Messages:
    2,487
    I hope so, it's just what I need! Maybe change its colour and alpha values and use the sphere around the player... that could be amazing!
  37. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    yes or just put a plane in front of the camera.
    I am thinking about doing some kind of water creature, or character to demonstrate that. But I need to see why the water is not looking good when it has negative y values... debugging.
    It is a case I never though about, but if you can make any mesh water animated, you get into some really cool CG Fx that are not usually possible in real time.

    Attached Files:

    Last edited: Apr 6, 2011
  38. MrBodean

    MrBodean

    New Member

    Joined:
    Jan 25, 2008
    Messages:
    103
    Any plans on foam for shoreline?
  39. grfxman

    grfxman

    New Member

    Joined:
    May 28, 2009
    Messages:
    309
    Yeah it's looking really good !! But still want to know if it's shader 2 or 3 ?
  40. AnomalusUndrdog

    AnomalusUndrdog

    Member

    Joined:
    Jul 3, 2009
    Messages:
    1,130
    You know you can actually even use this for a water elemental creature
  41. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    Shader 2 without transparency... Apparently needs shader 3 to have transparency... I need to investigate why.
  42. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    Yes the idea is on the way, I talk with one of the best artist for making monster that is on this forum, a French guy like me, if we make a deal I will post news in this thread.

    btw anyone has an idea about the price I could charge for this shader? I am not sure yet.

    - if it is too low, pirates will buy it quick and exchange it. Also it should not be lower than the price of one animated model for example as it asked me weeks of work
    - but if it is too expensive, Indies will not buy. But will they buy anyway, if they are cheap and broke?
  43. grfxman

    grfxman

    New Member

    Joined:
    May 28, 2009
    Messages:
    309
    Thats a tough question cause I'm a poor Indie Dev myself. I would guess close to your other shader prices, maybe a tad higher.

    Also I was thinking about an old post that allowed caustics on the ocean floor. Combined with this would be quite amazing.
  44. sebako

    sebako

    New Member

    Joined:
    Jun 27, 2009
    Messages:
    295
    I'd pay between 60-80$ for it, as indie I can't afford much more.
  45. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    No shoreline, it is something that cannot be done with this shader, because it is designed to be just like a procedural texture to be applied to anything. Shoreline should be done the same way a road or a river is done with a specific editor. Maybe the guy who does Road Rivers could add Shorelines in his package in the future, that would be perfect.
  46. soapstar

    soapstar

    New Member

    Joined:
    Apr 4, 2011
    Messages:
    56
    Hey Nikko,

    First off this shader looks fantastic, great work! I would be willing to pay at least $60 for it! :razz:

    However! Before i would think of purchasing this i cant get your free version (Free Ocean Technical Demo v4) to work! When i run this scene the water shader doesn't seem to work?!

    Here is a screenshot of what i get:

    [​IMG]

    Thanks for any help! :D
  47. nikko

    nikko

    New Member

    Joined:
    Mar 20, 2009
    Messages:
    436
    Please contact me in private or thru unitydx.com for that matter.
  48. heilong

    heilong

    New Member

    Joined:
    Jan 27, 2011
    Messages:
    2
    Salut Niko

    Je vais la faire en francais car en Anglais tu ne vas pas comprendre.

    Je suis impressionné par ce que tu as fait, je viens de passer 3 heures a tester le water3 et c'est vraiment impossible de donner quelques choses de bien, surtout qu'il me bug mes mesh qui viennent de 3dsmax. Donc j'ai cherché sur le net autre choses et j'ai vue ton post. J'ai aussi compris que tu vends ton shader, je voudrais savoir a quel prix car il m’intéresse.

    J'ai compris que ca fait un très long moment que tu es dessus, tu touches la fin ? Car la c'est vraiment impressionnant.

    Merci, je vais continuer a suivre l'évolution.




    Sorry to english, i speak very very bad english. I just say, that s awesome, and the shader's price.
  49. unity3dx

    unity3dx

    New Member

    Joined:
    Apr 15, 2011
    Messages:
    175
  50. unity3dx

    unity3dx

    New Member

    Joined:
    Apr 15, 2011
    Messages:
    175
    Smart Water needs Shader 2 for using all its features.