Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Feedback Stylized Water Shader (FREE!)

Discussion in 'Assets and Asset Store' started by alexanderameye, Mar 13, 2020.

  1. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    272
    Alex when hdrp version come out?
     
  2. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I'm currently working on the 1.1.0 update. HDRP is planned, but I will probably release it as a separate asset called "Stylized Water For HDRP". As an existing customer of Stylized Water For URP, you will then be able to get the HDRP version as well for free or for a small price of $5, so you won't have to buy the HDRP version separately.

    I choose to do this because I think it will cause less confusion or errors for users if the 2 versions are split up. If you use HDRP, you can download the HDRP package and if you use URP, you can download the URP package.
     
  3. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I just tested compatibility with Unity 2019.4 LTS and there seem to be no issues. The only thing you'll notice is that the support window doesn't detect 2019.4 as a supported window. This won't affect the functionality of the shader of course.

    I will fix this UI issue in version 1.0.4 which I'll submit this weekend.

     
  4. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Working on shoreline foam movement, you can make foam move towards or away from the shore.

     
    Lars-Steenhoff likes this.
  5. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    272
    this is really what i want like Animal Crossing!!!!!!!!!!!
     
  6. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    272
    only different is in animal crossing the wave is move from center to edge.
     
  7. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    272
    Hello Alex, is there any way to use this water with correct effect less than 2000 render queue?
    I m trying to make a pond with depth mask
     
  8. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    If you select the material in your project window, you can then set the render queue in the inspector.

     
  9. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    272
    yes I know that, but it will bring strange effect.
     
  10. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Small development update.

    Currently still actively working on update 1.1.0. Already very happy with how it's looking. The upgrade will bring a lot of new features as well as improvements for all the aspects of the shader.

    The update is on track to be released in August :)

    After that I'll try to update more frequently, but the updates will be smaller, with incremental improvements and added features.

    If you enjoy the asset and you haven't written a review already, please consider taking the time to write one, they are very helpful to me. Have a nice weekend!
     
    ununion and fullerfusion like this.
  11. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Last development update before the actual release!

    The update is pretty much done, I'm just finishing up and need to work on some promotional imagery. I have to say, some features that I planned for this update were scrapped for different reasons. I'll post a list of all the changes and additions once the update is released.

    Here is a video showcasing the new water caustics!

     
    fullerfusion and Lars-Steenhoff like this.
  12. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,465
    Looks amazing!
     
  13. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,465
    Did the shoreline foam movement make it in this update?
     
  14. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Yup it did, but I marked the feature as 'experimental' since I still want to improve on it. The main improvement that could/should be made is to work with a static depth capture. Basically you put a top down orthographic camera over your scene and capture the depth of the scene, then you use that depth for all your depth effects. This has several advantages, mainly it will get rid of perspective issues.

    You'll notice that in this post about shoreline movement, the foam kind of looks like it's 'following' the curvature of the sphere object instead of just moving outwards, personally I think this isn't a very big issue but it can be improved upon by using the method mentioned above.

    I hope to provide the option to work with an orthographic camera to capture depth information in a following update so that the effect will look even better.

    Here is how the inspector looks for shore foam.



    Cheers,

    Alex
     
  15. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,465
    Great to see that!

    I actually really like that it folllows the curvature of the shore line!
     
  16. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383


    I finally pushed update 1.1.0 to the store and it should be released before the weekend if everything goes well. Here is the changelog (there might be more changes but these are the most important ones).

    Important! Before importing version 1.1.0 you'll need to remove the Stylized Water For URP folder completely and then you can import the asset again. My apologies for this inconvenience. I made a lot of changes to the asset and so you'll have to redo your water, keep this in mind.

    Added
    • HSV color lerping option for more vibrant color transitions
    • Wave colors
    • Improved color blending between foam and water
    • Shore color option
    • Caustics can now be drawn using a custom renderer feature
    • Caustics can now react correctly to sunlight direction
    • Caustics can now be rendered underwater
    • Improved controls for caustics rendering height
    • Shore foam movement (experimental feature)
    • Improved fading options for foam
    • Wave height mask for surface foam
    • Foam can now cast shadows
    • New planar reflections component
    • Basic underwater effects
    • Rewritten lighting functions
    • Diffuse and specular color options
    • Toon lighting effects
    • Fog support
    • Additional light support
    • Rewritten refraction functions taking into account surface normals
    • Basic buoyancy functionality
    • Option to switch to local space UVs instead of world space UVs
    • Additional checks in the support window
    • Included more foam, caustics and surface normals textures
    • Added more demos

    Changed
    • Redesigned material editor for improved usability
    • Water features can now be toggled on/off to save on performance
    • Reorganized all shader graphs and subgraphs
    • Removed mobile shader variant
    • Added Discord contact option in support window

    Fixed
    • Fixed moving caustics bug introduced in SRP 7.4.1

    I still need to update the documentation to reflect all of the changes made in this update and will do this in the coming days. I did my best to test out this new update as best as I can, but there still might be small bugs or small issues. Thank you for being patient and kind regarding this.

    Now I need a vacation :)
     
  17. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Well, that was quick! Update 1.1.0 is now live :)

    https://assetstore.unity.com/packages/vfx/shaders/stylized-water-for-urp-162025

    Important! Before importing version 1.1.0 you'll need to remove the Stylized Water For URP folder completely and then you can import the asset again. My apologies for this inconvenience. I made a lot of changes to the asset and so you'll have to redo your water, keep this in mind.
     
  18. RaoulWB

    RaoulWB

    Joined:
    Feb 9, 2014
    Posts:
    14
    Hello! I'm loving your asset and just updated to the newest version. After some time trying to get it to work correctly I now have this error which I don't really know how to fix:
    " Shader error in 'Stylized Water/Stylized Water URP': 'TEXTURE2D_ARGS': Too few arguments to a macro call. at WaterLighting.hlsl(108) "
    Upon folder reimport I also get this similar error:
    " Shader error in 'Unlit Master': 'TEXTURE2D_ARGS': Too few arguments to a macro call. at WaterLighting.hlsl(108) "

    I've already tried reinstalling the asset completely. I'm on Unity 2020.1.0f1, using Universal RP version 8.2.0.
     
  19. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey, I haven't experienced that issue before. Do you get the same errors in a new, empty project? Did you change some of the code in the WaterLighting.hlsl file?

    I just made a new project Unity 2020.1.0f1 and do not get the error.

    Do you have any red checkmarks here?



    Cheers,

    Alex
     
  20. RaoulWB

    RaoulWB

    Joined:
    Feb 9, 2014
    Posts:
    14
    Nope, no red checkmarks. And no, I didn't edit any of the code, I did mess a bit with the shader graph nodes back when I was getting errors about not finding the hlsl file; now to be 100% sure I've just deleted and reimported the asset again, so I can say for sure that no file got edited in any way.
    upload_2020-8-28_11-58-14.png

    The moment I create a material using the "Stylized Water/Stylized Water URP" shader I get this same error again, here's the full screenshot of it:

    upload_2020-8-28_12-10-48.png
     
  21. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hmm I still can't reproduce it.

    Could you maybe try opening WaterLighting.hlsl and go to line 107 and change the code to this.

    Code (CSharp):
    1. ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();
    2. half4 shadowParams = GetMainLightShadowParams();
    3. ShadowAtten = SampleShadowmap(TEXTURE2D_ARGS(_MainLightShadowmapTexture, sampler_MainLightShadowmapTexture), shadowCoord, shadowSamplingData, shadowParams, false);
    Edit: I just submitted a minor update that might solve the issue but not sure.
     
    Last edited: Aug 28, 2020
  22. RaoulWB

    RaoulWB

    Joined:
    Feb 9, 2014
    Posts:
    14
    Thanks! With that edit it seems to work now!
     
    alexanderameye likes this.
  23. neptoonism

    neptoonism

    Joined:
    Aug 19, 2019
    Posts:
    18
    I also got the same error and it was resolved with the edit to WaterLighting.hlsl - using new urp project template 2020.2.0a19.2490 and urp 8.1.0. Also had to edit Stylized Water URP.shadergraph and save it before being able to select it as a shader.
    Absolutely beautiful asset as well, thank you very much!
     
    Last edited: Aug 29, 2020
  24. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Thank you! I submitted a small update that should help with some of these issues. If you enjoy the asset, a review would always help me out greatly.
     
    Lars-Steenhoff likes this.
  25. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Last edited: Aug 31, 2020
    DrOcto, Shodan0101 and Lars-Steenhoff like this.
  26. Shyjay

    Shyjay

    Joined:
    Mar 29, 2016
    Posts:
    6
    Hi Alex,

    Great Asset you got there. I bought it a week ago when I moved to URP from the built in Render Pipeline.
    Currently I'm working on a mobile game where you sail around with a ship(so plenty fo sea to see). I was optimizing quite a lot of stuff and am mostly testing on my low end/low middle class device (Honor 9 lite).

    I tried around a lot because my fps on the device were terrible and optimized all my own stuff. When Draw Calls/Batches and Profiler didn't get me good answers I checked your asset and found it to be the bottleneck.

    I get like 3 fps with intersection effects and surface foam activated (intersection shadows disabled ,surface and lighting disabled, though refraction is set to a value)
    With basically everything disabled (no surface foam, no intersection effects, no foam shadows, no caustics, no planar ref, no surface and lighting (and no refraction) and even waves disabled I get around 10 fps

    If I deactivate your asset I get around 35 fps. I checked your mobile demo where I get between 15 to 20 fps.
    What could cause this? I got everything checked under the checkboxes (tools/stylized water for URP).

    And also I wanted to ask if it would be possible for you to share the stat analysis script/overlay from your mobile demo - would be great to check my scene with it.

    Here are some Screens:
     

    Attached Files:

  27. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey! I'm sorry you're having these issues. I'll do some performance testing on my own mobile phone and get back to you.

    For the fps counter I use this script. https://assetstore.unity.com/packages/tools/utilities/advanced-fps-counter-14656
    It's great but you can also find free alternatives on the store of course.

    Also, could we move this conversation to Discord? It might be a bit easier.

    https://discord.gg/6QQ5JCc
     
  28. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Stylized Water For URP is -50% off in the current sale!

    You can get it here !

     
    Shodan0101 likes this.
  29. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,465
    Hi, can you tell me the settings to create the shoreline foam with curvature ?
     
  30. Admin_Friend_Factory

    Admin_Friend_Factory

    Joined:
    Oct 23, 2018
    Posts:
    41
    Hi! Has anybody got the latest Stylized Water to work on iOS with Caustics (with URP Renderer)? It works on Mac in the Editor but not on iOS for us. I am on version 1.1.0 and URP 7.4.1 / Unity 2019.4.3. Thanks
     
  31. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Keep in mind that this feature is experimental.

    These are my settings.



    And I get the following effect.

     
  32. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,465
    Thanks, I see you put the speed at minus, I was already wondering how to reverse the direction. Nice to see its so easy
     
    alexanderameye likes this.
  33. MghtyMax

    MghtyMax

    Joined:
    Oct 8, 2018
    Posts:
    5
    Hi ! Thanks for this incredible assets, very good job !

    However, I have a small problem. The buoyancy applied to an object does not take count of the size of the water mesh, and the object continues to float even out of the water.

    I tried to change the script a little but i haven't found a solution right now.

    If you have a solution to this problem, that would be awesome !
     
  34. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey, that's good to know! I'm going to look into this. What kind of game scenario do you have going on? A boat entering the water?

    Possibly you could make this work by making your buoyant object do a raycast and check if the water is below it.

    And if you enjoy the asset, a review would always help me out greatly :)
     
  35. MghtyMax

    MghtyMax

    Joined:
    Oct 8, 2018
    Posts:
    5
    I'm making a short narrative game, with somes physics sandbox features, so you can throw objects in a pool/bath/washbasin.

    I tried to check with a raycast, but if i deactivate the functions of the buoyancy script, it seams to lock the physic of the object and it just make it slide on the air, very weird.

    https://giphy.com/gifs/LSEU4I5xBNZTG7Rk3R

    (I already write a review btw ;))
     
  36. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Aha! Right that's a nice use case.

    So yeah, I think the issue might be that on the Awake function of the buoyant object, I set the rigidbody to not use gravity.

    Maybe you could try to add a function like this to the buoyant object script?



    And then enable/disable the buoyant component based on that raycast and so the rigidbody will be set to use gravity again when buoyancy is disabled and the object needs to fall to the ground.
     
  37. MghtyMax

    MghtyMax

    Joined:
    Oct 8, 2018
    Posts:
    5
    Okay I didn't see that the gravity was deactivated, I need to check my inspector more :rolleyes:

    The script you given didn't work for me but I've solved the problem by checking the gravity of the object if deactivated with Playmaker (yeah i'm not a very good programmer)

    Well, thanks for the help, If someone has the same concern he will see it here.
     
    alexanderameye likes this.
  38. drallcom3

    drallcom3

    Joined:
    Feb 12, 2017
    Posts:
    162
    Nice asset.
    Works fine (as far as I can tell) with 2020.2b1 and URP 10.0.0-preview.26.
    The troubleshooting page covered most of my issues.

    I had a problem importing it. Turned out I may not move the asset in a different folder (like in assets/prefabs/). The shader can't find things then.

    The documentation under support/performance: Additional Lights is cut off mid-sentence.

    Caustics do render a bit above the water, but it seems you're working on it.

    I also had to restart Unity after importing to make the asset work.

    I had to move BuoyantObject.effectors up, because the inspector didn't work when it was the last object (when the list is collapsed it vanishes).

    Planar reflection do not take waves into account.
     
    Last edited: Sep 12, 2020
  39. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey, thank you for the feedback. I'd like to address some issues you had.

    1. When importing the asset, sometimes Unity messes up the references for shadergraphs it seems so sometimes the shader graph has a hard time finding the referenced .hlsl custom code files. In the asset, I do not use any absolute path references, just references to a file, so in theory you should be able to put the shader anywhere.

    If you do get any errors like this saying 'failed to open source file', on import or after moving the folder.



    You can try to right click on the Stylized Water For URP folder (or its parent folder if it's not directly under Assets/) and click 'Reimport'. Sometimes that helps Unity to get the references. But so yeah, I don't use any absolute path references, just file references and I expect Shader Graph to improve this in the future.

    I tried moving the folder in my own project and indeed I got those errors, but using the reimport trick fixed that.

    2. Thanks for letting me know about the documentation! I updated it.

    3. What do you mean with caustics rendering above the water? Indeed the new caustics system will just render caustics 'in the world at a certain height', it does not 'know' where the water is. You can always try to use the old method of rendering caustics if you'd like.

    4. Did you have to restart because of 'Failed to open source file' errors?

    5. What exactly do you mean? I think I'm doing regular gameobject references.

    6. Yes, planar reflections do not take into account waves, I'll put this on my list and look into it.

    Thanks again, have a nice day :)
     
  40. drallcom3

    drallcom3

    Joined:
    Feb 12, 2017
    Posts:
    162
    Yeah, that was it. The default value is 2 (I think) and my water was at height 0. A default of 0 might make more sense and works fine for me (now).

    No errors. Might have been a fluke, because in a fresh project it didn't happen.

    Might be a 2020.2 thing. They updated inspector stuff and especially arrays.



    My project looks a lot better now with your water.
    One question: How would I make a large ocean, but only have the center detailed (player can't move around)?
    Right now I made a second water object for the distance, scaled it super big and disabled almost everything (I really only need the color and skybox reflection to make it look seamless with the central part).
     
  41. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey,

    For large oceans it's indeed ideal to work with levels of detail. You can use a plane mesh in the center with higher density, and then the rest can be lower density. If you use world space uvs, everything like foam and waves will match up.

    If you'd like, join the discord and then I can send you a custom version of the shader that's more lightweight that you can use for distant water planes.

    https://discord.gg/6QQ5JCc

    So like, work with tile system where you have 'ocean tiles', each with their own vertex density.
     
  42. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,741
    anyone got the android apk working? I downloaded it and the phone says it can't run it. Not sure if it's compiled for 64 bits or opengl 3 or something. Is there a 32 bits and opengl 2 version?
     
  43. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    Are there any settings for level of detail? I have this strange problem, where on a 15x15 size quad using the beach shader, if I pan the camera to the further corners, the water reflections and intersection effects are quite pixellated. I don't want this to happen, but would like consistent quality edge-to-edge.

    Otherwise am loving this asset! Certainly hoping to use it in one of my future games.
     
  44. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Do you have an image of this? I'm having a hard time understanding what you mean :/
     
  45. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    Hey, thanks for the response. I attach two images. One is at the left edge, where the camera starts. You can see the foam on the water is nice and smooth. On the other image, at the right edge, if I move the camera, you can see that the foam on the water is very "blocky," pixellated. Both edges are part of one and the same quad.

    Also, the foam at the shore intersection -- is there a way to make it wider? Changing the scale of the foam changes the scale of its detail, but not how far from the shore the foam reaches...

    IMG_1365.png IMG_1366.png
     
    Last edited: Sep 30, 2020
    StaggartCreations likes this.
  46. Saad_Khawaja

    Saad_Khawaja

    Joined:
    Dec 12, 2013
    Posts:
    31
    Hi,
    The water is coming off as completely opaque in the build on iOS. It is fine (transparent) in Editor. What settings/changes do I need to make?
     
  47. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
  48. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey, with what foam texture do you get this issue? I'll test it out. Maybe it's just a bad texture, or maybe you need to disable 'generate mip maps' in the import settings.

    For the foam, you can choose how far it extends by changing the depth slider.

     
  49. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    Mipmaps were off. Tried turning them on, same issue. It is Foam 1 that I am using. I tried the other ones as well to compare and it's the same for all. I'm attaching another example, with Foam 4. One thing to mention is that I only see this happening when published, not in Unity Editor. I'm testing on iOS.

    resolution_good.png resolution_bad.png

    For how far it extends, is there a way to do it without depth? That is causing issues for me, because the foam starts appearing in the middle of the water instead of just extending gradually. Image attached.

    Intersection_A.png Intersection_B.png
     
  50. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I'll look into the issue with the texture!

    And yes there is another way to draw intersection foam. If you are able to join the discord server I can help you out there regarding that.

    https://discord.gg/6QQ5JCc

    Or email if you can't join discord. alexanderameye@gmail.com