Search Unity

RiverWater: the free epic water solution for unity free users!

Discussion in 'Assets and Asset Store' started by FuzzyQuills, Mar 23, 2014.

  1. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    2022 Update: I have fixed the permissions on the download which got changed to restricted. It is now public again. ( I suspect this may have happened when the web hosting parts of Drive shut down)
    With this said I would be very surprised if this package still worked in modern Unity. (>2017.4)
    If there are any issues, please DM me, I don't check the forums as much as I used to (I no longer work with Unity full-time) but I do get notifications via email still!

    For the old webplayer link, if I can host a WebGL version instead, I just might...
    Again, very surprised this asset is wanted again, since it had been designed for Unity 4.x originally.

    Edit 2: Apparently Google Drive downloads just don't work anymore; I've taken the link down while I figure out a different file host.

    2017 update: Being as this thread has been brought up quite a few times, I will do what I promised and bring a water asset out to replace this one. It's currently very usable right now, but requires adding a section of code to your vertex shaders, which is a little much for some people. I'm working on a CPU based code path as a result.


    River Water for Unity Free


    Hello, and welcome to my River Water Thread! Often wanted a water shader that isn't bluey-colored goo on Unity free? Sure, there is a lot of solutions to this, but many of those cost money. So here i present you: the free Option for Unity free water!

    The features? Here is a list of things this shader can do:
    • Real-time refraction!
    • Down-scaling of textures for performance vs. quality!
    • Plenty of sample wavemaps and textures to get you started! I can add more if you like me to, and if you have a good idea for the default textures, go ahead and post the samples!
    • Attempts to emulate CryEngine Relief mapping by using parallax distortion and self-shadowing. this is achieved by tinting dark areas on the water a particular color.
    If you need help, either consult the MANUAL.RTF file, or come post a question here! I assure you that you will get an answer in less than 24 hours if you do! Guaranteed! If you wish to contribute, simply post your contribution here for the world to see, and it will be included in the package, unless you state otherwise!

    Happy Deving!

    -FuzzyQuills

    Links:

    Download mirror:
    [Update 2022 - Link removed due to technical issues]

    Webplayer for those who want to see this water right away!
    LINK

    link broken by closure of Google Drive web hosting, the Unity web player is also no more
     
    Last edited: Apr 20, 2022
    o0_ICE_0o, FaberVi and Torigas like this.
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,140
    How did you get refractions working in Unity free?
     
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I used ReadPixels to do it. And that is what the quality setting is for: It means you can have it only render up to an eighth of your display res! This ensures that games that use terrain or are high-poly don't lag as bad as if the ReadPixels captured full-res each frame. And if you have a Nvidia GPU, this should perform nicely.
     
    shkar-noori likes this.
  4. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Its fair effort, but you should give the water some variation of flow, and also follow the course of it(the river). Theres nothing fast about readpixels on my nvidia card, which is quite strong, so i dont know where you got that from
     
  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @lazygunn:

    Where i got my info from: At my TAFE college, every computer has a Nvidia quattro, and this ran at more than 60fps on the card. perhaps you can state the model of card you have? This should run at more than 30fps on the lowest quality/performance setting. (1 is best quality, 8 is best performance, presuming you downloaded this and tested it)

    It isn't readPixels that's the overhead: it's texture2D.Apply(), and by doing a couple of tests, downscaling the size of the texture makes the Apply operation faster. This is why the quality setting is there: it means you can still have refraction with a minimal performace hit. (there is artifacts on lowest setting though, but that shouldn't be a problem unless you have trees or other objects in the water.)

    If you want an example of how a river can be made with this shader, try building a mesh with the river drawn as a path, then set the shader up. (the mesh in the demo is actually a flat plane!) I can post another demo to prove this if you want. I also have animated normal maps on my todo list for this shader, which may give a better variation for it. My PC has an Intel card, and running the demo on setting 3 or 4 gave a solid frame rate.

    Long story short: ReadPixels isn't the fastest method, but given a proper tune-up, ReadPixels can run frame-by-frame at a reasonable speed, which is, again, the reason why there is a quality setting.
     
    Last edited: Mar 24, 2014
  6. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Using the new water and the waves are nice. Also love the texture scaling.

    The only issue I am having is with the specular not working and the water looks a little bland up close. With the last water you had two normal maps overlapping. That gave it a lot of detail. It think you need the two normals plus the wavemap. If that is possible.

    Do not know why the specular is not working. There are some highlights opposite the sun's direction but none looking towards the sun.

    Does this newest shader use Lux? I know you were planning on it but not sure if you implemented it yet.
     
  7. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Was that more than 60fps with vsync on or? Because thats ridiculously slow for one aspect of a game's appearance. Without the terrain, this https://www.youtube.com/watch?v=vmwdP4OFgtI runs at about 400fps and its an old 580gtx. Code using readpixels etc to do an effect where in pro you'd use a rendertexture (fast) is very slow, i used similar in my efforts to get the oculus rift working on unity free and it was very slow, especialy when you take into account your game won't just have a river in it.

    I haven't tried it myself but Mono.SIMD: http://forum.unity3d.com/threads/183369-Using-SIMD-in-Mono-or-using-the-GPU might give you ability to process 4 pixels at a time, which would speed things up. Haven't tried it though so i cant tell if its relevant anymore
     
  8. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Looks pretty cool man :D I might grab this just to have some water in my levels as an ambient effect. Looks pretty good, and you can't beat free!
     
  9. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @baldinoboy: I was planning on lux, but that water shader you have there is slightly compromised: that was a full rewrite after the import of the Lux shader deleted the original! So yea, i stopped using two noral maps becuase of weird shapes forming in the water. I am not sure what the specualr is doing, and i currently have no fix for this until i figure out what the shader is doing that is screwing with the specular highlights!

    And sure, I can add two normal maps again if you like;

    @Velo222: thank you velo! good to hear!

    @lazygunn: I am used to 60fps on my PC, due to it's poor graphics. And i actually got my demo to run at 80 on my intel HD, which is at least 100 times weaker than the card used in the water demo. That was, however, without the terrain engine, which is quite expensive to render on it's own, let alone than having my water in it too!

    I can give the link you posted a try. And if you want proof of speed-ups in my package, then download my package, set up a scene, then turn the quality all the way down to 8: it should run real fast! (at least 60fps, at most 80) In the meantime, i will see what i can make use of in the article you posted. And that terrain in the youtube clip is probably missing the optimizations i have given mine. ;)

    BTW: the slowness isn't readpixels, its Apply() that kills the performance. all UT need to do is to make the in-game version of Apply() a tad faster...

    EDIT: the article seems to require a plugin, which is unfortunately Pro-only, so that's out...
     
    Last edited: Mar 25, 2014
  10. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    You said it was 60fps on your colleges workstation cards, but 80 on your computer. Do you have vsync on in the settings and do you get the fps from the editor stats window?

    And you can run mono/.net dlls from unity free i think?
     
  11. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    @FuzzyQuills: Sounds good. Did not know if that specular problem was just me.
     
  12. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @lazygunn: being a webplayer demo, the 60fps figure may be incorrect... But from the performance, the workstation could have been running at 100fps. Since my laptop has Unity installed, i simply turned on the graphic overlay in the play window, and looked at the framerate, which at one time was 80 to 100fps on high setting.

    @No, the specular problem seems to be a hidden fresnel calculation and happens on my laptop as well. I am so sure i removed that...
     
  13. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    As far as I understand, ReadPixels runs entirely on the CPU so the performance of a method based on it will have absolutely nothing to do with the GPU.

    Nevertheless, nice work and thanks for the contribution to the community!
     
  14. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @bac9-flcl: true fact! and thanks for feedback bro! If there was a way of speeding up ReadPixels, i would go that route, but for now, we are stuck here...
     
  15. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Any update on the shader? I know you have been busy with Indie Effects.
     
  16. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Oh yes, i actually fixed the specular prob, but unitl i get better wavemaps for CryEngine style waves, the pack won't be updated until this is done.
     
  17. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Cool. Thanks. Cannot wait to see the new specular. Is the specular going to be affected by both the normal map and the wave map?
     
  18. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Hopefully... I have been having issues with the normals not showing up right. (that's how the specular got messed up in the first place!) I am attempting to have the water self-shadow itself, like relief mapping, to give better realism. could do it with a fresnel mask, then blend over the top...
     
  19. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    That will be great. What about a complete relief mapping shader for the water? Is that too expensive on performance? Not even sure if you could animate a relief shader.
     
  20. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Ok guys, new version uploaded! this new version looks visually better than the last IMO, and is now attempting to emulate CryEngine waves!

    Bugfixes:
    • specular highlight not appearing in right place fixed. it was caused by incorrect normal mapping.
    • water now has emission mixed with albedo to attempt to emulate CryEngine waves. the wave distortions now undulate along wiht the textures to give better realism! you can change the "alpha" variable to adjust the weird tint on the water caused by this effect so it caters to your taste better.
    that is all for now. Enjoy!

    @lazygunn: I actually found that upping the pixel error on a terrain lowers the draw calls and boosts frame rate
     
    Last edited: Apr 4, 2014
  21. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey FuzzyQuills. Got internet back and have tried the new water. The normals look much better. The specular is still not working on mine. Also I cannot see the waves. I can see the shadow effect just not the actual wave.
     
  22. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Oh... could you post a screenie? i have no idea why you still can't see the spec! the new version coming has more visible waves than the previous, so that shouldn't be a problem anymore once it's uploaded!
     
  23. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Looking towards the sun-

    $Water_Specular1.jpg

    Looking away from the sun-

    $Water_Specular2.jpg

    The new update does look a lot better though. The normals are back to normal. Thanks
     
  24. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Oh yea, kinda odd actually. I started a project that uses this shader, and believe it or not, i fixed the specular in that project. will probably add the changes to the project and upload them soon.
     
  25. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    One thing I did which improved the wave effect was disable Generate Mip Maps on all the water textures.
     
  26. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I actually thought of using something similar to speed up this and IndieEffects... i presume using mip maps takes power to generate, depending on texture size.

    I am also looking into actual relief mapping... Or was. at the moment, i am working on a game i hope will be my first one that gets released, and as a result, the water shader may not be updated for months! But i will see if i can speed this process up and get the water shader good and complete when i get time amongst my project and school work.
     
    Last edited: Apr 21, 2014
  27. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I think mip maps actually save on rendering but use more data. :confused:

    Relief mapping would be awesome. Hope your game comes along good.
     
  28. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Baldinoboy: Thx bro. and yes, a mip map uses more memory!
     
  29. bandidoman

    bandidoman

    Joined:
    Feb 18, 2014
    Posts:
    1
    Hello Fuzzy Quills, thanks for this solution it looks wonderfull, the only problem we seem to have is that in your demos the waves are animated, they seem to move. After following the instructions, everything seems to work correctly except for the animation, our water is completely still, what are we doing wrong? Are we missing something?
     
  30. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Hi, FuzzyQuills. :)
    I have a simular issue to bandidoman's. I load my project with terrain etc... I load you shader and do what is written in the readme file. The water or sth like a buble mesh appers with applied colors but when I play the scene the water remains static (looks like I said, as a mesh full of bubles). I want the water to act like water, so...as it looks I need some help and if you can help me it would be good.
     
  31. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I have not used this in a while but I remember having to attach the river water script to the main camera and placing the water planes in the appropriate slots. Then select a speed. I think I used something like .001. If you already did this and it still does not animate then I do not know.
     
  32. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    I'm very puzzled about what happens. I made a material, gave it all the maps needed plus I set values of the variables for tilling and offset so that the tilling ones are bigger then the offset ones. I made a plane, a camera and added the material to the plane and the java script to the camera. In the java script on renderers I wrote 1 and in the slot given I placed the Plane. I Hit play and.... nothing happens it's just a texturised plane. Oh,... after the first execution of the scene in scene view the plane with the material attached to it becomes pure black, however in play mode it remains bluish.
    See how it looks like:
    http://prikachi.com/images.php?images/74/7721074j.png
    http://prikachi.com/images.php?images/75/7721075j.png

    I forgot to add - yes, I changed the layer of the plane to "water", the refraction is on. The water stays static. I'll ask you for two things.
    If you can help me just by detecting my error from the screenshots I've given then, please, tell me what I'm messing up:)
    If it's easier for you and it's not too fastidious from me, please make a scene with a working water and send it to me/upload it here. :)
     
  33. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Here is a quick demo. It works fine on my computer. When exiting play the water does turn black but when saving it returns to its diffuse.

    Delete the RiverWater folder in your project before importing this.

    Here you go: RiverWater_demo

    Hope it works.
     
  34. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Yeah, yours work and I want to thank you for the help... but it is strange again. I understood how to fix the 'pure black' effect - you have to apply every time after running a scene with this water shader, the shader... however it's not a big deal because even if it's black it works. So, the problem is - if tI move the main camera to other part of the plane and run the scene it looks static, again. Also, if it's close - it works, if it's far, gets static...
     
  35. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    It is still moving but because you are far away it does not seem to be moving. Like the real ocean at high altitude or anything else that is not fast moving at high distances. Increase the flow speed in the river refraction script on the camera to 1. You should notice movement at a distance.
     
  36. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Thank you so, SOOOOOOOOO much, Baldinoboy!!! You were right it was all about the flow speed. I've finally understood how simple it is and made my own water plane - working :)
    http://prikachi.com/images.php?images/9/7723009p.png

    Thank you for being so patient with all the dummy questions but I've to start from somewhere. :)
    P.S. A last dummy question but not a necessary one to answer - how could I create wave maps, refraction and normal maps from a single water image? I have Crazy Bump on my computer and it does great job for any types of material but I'm not quite sure about getting the all three maps at once...
     
    Last edited: Nov 14, 2014
  37. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Cool:). Glad you got it working. Do not worry about the questions. We all have them;).

    In this shader the wave map is just the larger waves normal. The refraction is grabed from the refraction camera so do not put anything in that slot. Never used Crazy Bump but pretty sure it is similar to normal map creating in GIMP.

    Get yourself a nice water texture for the smaller waves and one for the large waves(wavemap). Not the best at getting good water textures so maybe when you get it done let me know how you did it.

    What I do is move it to GIMP-greyscale it-contrast it properly-paint any extras in-normal map it. Crazy Bump should do a great job at it.

    Here is an image of the diffuse to height to normal(sorry could not find a water texture):
     
  38. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Thank you sooo much. Finally I made a full-functional water with all the refractions and so on. THANK YOU!!! :)
    You can see my last results in the attached file below.
     

    Attached Files:

    Baldinoboy likes this.
  39. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Awesome man. Looks really nice.
     
    KDX2 likes this.
  40. AramShahbazians

    AramShahbazians

    Joined:
    Jun 3, 2014
    Posts:
    16
    Hi, I have a problem with the water. It worked fine for weeks while going on with the project and now it changed, I don't know why. Maybe someone can help me? All of sudden it's not transparent anymore and it's reflecting the skybox and part of my background mountains. I have an older project where the water works fine but I can't understand what did I change. I tried re-importing it but in this particular scene it's just weird. If someone can help me I'll be really glad. I'm attaching an image with the problem, a screenshot of the project with the water working properly (with transparency) and the settings.
     

    Attached Files:

  41. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Make sure that you've not textured the bottom of the river black. My other suggestion is that it somehow deleted the directionl light. Make sure you have one. The last that came into my mind, I had the same issue with the black water, after playing the scene water to get black-colored. I came across that you can fix it by simply reloading the water script in the menu you've screenshoted, the last image, which's 68.7KB. Just kick the dropping list and reselect the riverwater script, yeah it's marked I know but.. just try it. Try those things if nothing changes then tell us the results.
     
    AramShahbazians likes this.
  42. AramShahbazians

    AramShahbazians

    Joined:
    Jun 3, 2014
    Posts:
    16
    Hi KDX2, thanks a lot for answering. I'm going crazy over this problem. I've already tried all those options, I even created another river re-importing the package in Unity from the beginning but the result is the same. In the end I tried to copy paste the river from the old project (where it's working properly) but in the new one it has that weird behavior, reflecting everything 100%, so I suppose the problem is with some setting of the map and not with the river. Do you have any idea of what could cause it? Maybe some terrain or render setting? I already tried to play with them but nothing changed.
    Thanks again.

    p.s. The bottom of the river is stony and in the old version you can see it through the water (see picture)
     

    Attached Files:

    Last edited: Nov 20, 2014
  43. AramShahbazians

    AramShahbazians

    Joined:
    Jun 3, 2014
    Posts:
    16
    I made a couple of tests and the problem lays when I check the Refraction setting. Maybe there's something wrong with the camera. I'm checking the script now.

    EDIT: The only difference I found is that in the working version the Refract Camera has the Viewport Rect with width=0.333 and height=0.333, while in the version with problems width and height are 1. I don't know why they're set in a different way (the new project has just a couple of trees more) and I don't see how it could affect the water.
     
    Last edited: Nov 20, 2014
  44. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Hahahahaha, I think I've got it. If I'm right it's very simple. I took a closer look on your settings and I think it's the spectacular RGB color which causes the issue and it's not an issue, right. See, you've set it to black, all your colors are set to black, except the bottom one. All you had to do was to play with those color corrections/settings...

    Now, I've a question. Something came into my mind... I'm going to create an island and I plan for using riverwater as the 'ocean'. The thing I want to ask is, if I do it, would it slow down the game or the water simulations works only when watching the water? If the water is non-stop consuming CPU performance how can I do it so to be able to turn the water to inactive while not watching it, to salt up some calculation power?
     
  45. AramShahbazians

    AramShahbazians

    Joined:
    Jun 3, 2014
    Posts:
    16
    Sadly I already tried that. I played with every kind of color known for every parameter. The problem is related to the refraction alone, I'm still investigating though.

    About your question, the problem is not the water but the script for the refraction. It causes a huge drop in FPS. I use it for a small river so I set a trigger collider which enables it when you're close to the water and disables it when it's out of sight. I guess you can do a similar thing. Being an ocean it can be tricky but I think it's manageable with a couple of colliders.
     
  46. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Yeah, thanks. Then, I'll use triggers, ook. About your problem idk. Try to reduse the Base Dist. in the Terrain settings and to add an material to it, if not. It becomes more and more misterious... :\
     
  47. AramShahbazians

    AramShahbazians

    Joined:
    Jun 3, 2014
    Posts:
    16
    Nope, the problem is still there. I still think it has to do with the refraction camera but I can't figure out how. Maybe I should pm FuzzyQuills :|
     
    KDX2 likes this.
  48. AramShahbazians

    AramShahbazians

    Joined:
    Jun 3, 2014
    Posts:
    16
    Ok a little update.
    Looking at the code it's clear that the refractions on the water surface are done through the RefractCamera which is created at runtime and is setted according to our character camera. What you see in the RefractCamera is projected on the surface of the water. My problem is that the RefractCamera is seeing what's under my terrain, but it can't be a problem if the code, it should be related to my main camera or terrain settings. Still I don't understand why there's no transparency of the water, it's like having a mirror.
     
  49. TheOneKevin

    TheOneKevin

    Joined:
    Sep 28, 2014
    Posts:
    1
    Did you turn on refractions in the River script attached to your script?
     

    Attached Files:

  50. KDX2

    KDX2

    Joined:
    Apr 21, 2014
    Posts:
    12
    Any ideas why is that happening? This is an Android project. I'm not sure whether it's connected ot a water issue, or it's the controls. Please, give me some ideas, or the solution :)
    It's either the plane or the camera! But I still can't understand what causes this behaviour.
     

    Attached Files:

    Last edited: Dec 7, 2014
    FaberVi likes this.