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

Feedback Stylized Water Shader (FREE!)

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

  1. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    Screenshot_20200515-115919.png Screenshot_20200515-112510.png Screenshot_20200515-112510.png

    It looks like this.

    (I feel I have to justify myself because the screenshot suggests that you have to buy stuff ingame with real currency, which is something I dislike ... it's an ad free free educational app for my kids where you can earn money doing math problems and vocabulary quizzes and buy animals with it) :)
     
  2. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Ah that's weird, that isn't like the artifacts I was talking about. It definitely looks like the depth texture isn't being generated. Can you double check that you enabled it?

    Could you try building it using Vulkan as well instead of OpenGLES?

    When looking online, there seem to be some bugs related to URP/android/depth texture so maybe updating your SRP version might help as well.

    https://issuetracker.unity3d.com/is...-9-when-depth-texture-is-enabled-in-urp-asset
    https://answers.unity.com/questions/1696763/no-scene-depth-in-mobile-build.html

    If you let me know your specific Unity version, SRP version and build target, I can try to build it on my own device and see what I get.
     
  3. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hey Alex, how can i get the same reflection effect like persp but in iso camera?
    please have a look at these two pictures,
     

    Attached Files:

  4. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Try changing the strength and scale of the refraction effect. When switching to an orthographic camera, you need to change some of the variables. If you want to change between perspective/orthographic within your game (at runtime), you'll probably want to change these variables with a script.
     
  5. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    Sorry, to be a pain. This took quite some time ... but in the end vulcan only is even worse...Maybe I'm just doing something wrong?
    Cheers,
    Volkererror
     

    Attached Files:

  6. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hmm, and so you are sure you are generating the depth texture? And updating your SRP version doesn't change anything? I definitely haven't encountered this. I'll try another Vulkan/OpenGLES build on my device and see if I can reproduce it.

    Seeing your screenshots, this definitely looks similar to this issue. https://alexander-ameye.gitbook.io/stylized-water/support/troubleshooting#water-is-white
     
  7. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    I started the project using Unity 2019.3.13f1 four days ago, so I am quite confident everything should be up to date. And the issue "water is white" is something I encountered before but was able to solve, thanks to your troubleshooting page.

    I still believe I'm doing something wrong but am not versed enough to know what it is. Just to clarify: If everything looks alright in editor mode and in game mode and it renders correctly as a windows build and your support tool gives "all thumbs up" (everything is green) ... do I have to actively change something if I switch to an android build?

    Cheers and thanks again for your patience,
    Volkerror
     
  8. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Alright, I'll test this out myself and check if I can reproduce the issue. I'll let you know if I find something :)
     
    volkerror likes this.
  9. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    @volkerror Just a little update.

    With these settings I got the following result on my phone. I just imported the asset in a blank, fresh new project, just switched the target platform to Android and didn't change anything else.





    So as you can see, nothing special going on. This is on Unity 2019.3.13f1 and URP version 7.3.1.



    Just to be sure, check your project settings in the 'quality' and 'graphics' menus if the assigned render pipeline asset is the same, and that the opaque and depth textures are generated for that pipeline.

    Are you using URP version 7.3.1 as well? And are you maybe changing pipeline settings in any scripts of the game?

    Any other special things you might be doing rendering-wise with render features or lighting or anything?

    Maybe you could send your material settings or the material itself through dropbox or something, so I could try out your water material?

    If you check out this bug, it seems very similar to what you are experiencing. It's marked as 'fixed in 9.0.0' so let's hope it gets backported.

    https://issuetracker.unity3d.com/is...-9-when-depth-texture-is-enabled-in-urp-asset

    Do you have other android devices where you could test your project on?
     
    Last edited: May 15, 2020
  10. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    I'm at a loss. None of my scripts are changing pipeline settings. As far as I know, that is. But it's a very simple project with only a few low poly assets, so nothing too fancy.

    I've used three different android devices (same effect on each). The assigned render pipeline assets are the same in all quality settings.

    The only thing left is to check that the opaque and depth textures are generated for each. I'm a bit embarrassed to ask, but ... how do do that?​

    EDIT: Wow. That's strange. I've compiled it once more and now it works. But I have absolutely no idea what changed. So this will be very unhelpful to everybody else (for which I'm sorry), but at least now it works for me. ;-(

    Cheers and thanks for the support once more,
    Volkererror
     

    Attached Files:

    Last edited: May 16, 2020
  11. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    thanks my friend, i solved it, if you want to get same reflection effect, you should set settings in <refraction> tab
     
  12. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I'm happy that it works now. Very weird! And about the opaque/depth textures, just ask! :)

    So first, go to Edit > Project Settings and in the Quality and Graphics tabs, you have slots where you can assign RenderPipelineAssets. Check which asset you are using there, and locate it in your project window.

    So for example here mine is called URP Pipeline.



    Then, select it in your project window.



    Then select it, and in the inspector window you'll have 2 checkboxes to enable/disable the depth/opaque textures.



    My support window checks the active renderer and sees whether or not these are toggle on, but you never know, double checking doesn't hurt!
     
    pudd1nG and volkerror like this.
  13. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    Thanks! That not only cleared things up for me in general. I double checked the quality settings of an old backup and it seems I - contrary to what I thought and posted above - had not inserted the correct RenderPipelineAsset in one setting ... it still was the standard one, which comes with the URP packages. And obviously IT had opaque/depth texture disabled. I blame this weird unity bug, where the editor selection window just closes without selecting anything. :)
    Cheers,
    Volkerror
     
    Last edited: May 17, 2020
    alexanderameye likes this.
  14. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hey alex a stupid question here.
    please look at the pic,i made a simple shader for obj to use spriteRenderer,but it cannot show correct effect when stick in the water.
    the left character is correct effect using urp lit shader, so do you know how to fix it?

    the shader made by me is very simple ,just want to use 3d light and auto fit spriterenderer 's sprite (references "_MainTxt")
    QQ截图20200518165939.png QQ截图20200518165656.png
     
  15. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Is that PBR master node set to transparent?
     
  16. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    yeah , so can I get that effect in transparent mode? sry for trouble,if not its also ok
     
  17. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Try this (master node is opaque).



    And I use the following settings.



    I get the following result. Left is default lit shader, right is custom PBR shader. As you can see, they look pretty much the same.



    So you need an opaque shader to make sure the depth-sorting works, but then you also use alpha-clipping.
     
  18. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    thanks my friend for your help, real bad internet in my country so cannot reply you ,thanks again!
     
  19. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    thanks my friend for your help, real bad internet in my country so cannot reply you ,thanks again!
     
  20. Black_Raptor

    Black_Raptor

    Joined:
    Nov 3, 2014
    Posts:
    181
    Hi,

    Is it possible to do infinite ocean ?
     
  21. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I see 2 ways of making infinite water.

    Firstly, you could do something like this.

    https://twitter.com/adamgryu/status/1112783007566450691

    Where you have a water plane following the player. Since the water shader works with world space UVs, this will work nicely.

    Secondly, you could make a chunk-based system that spawns in water tiles whenever you need them (when the player is close). Again, the tiles will match up (even the waves) since the shader uses world space UVs.

    Here is an example of 2 water tile with the waves matching up at the edge.



    So out of the box, I don't include any scripts or anything that give you an infinite water system, but the shader definitely allows you to implement an infinite water system due to it using world space UVs.
     
  22. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I added some more things to the troubleshooting section related to edge artifacts.



    This may be caused by textures that are generating mip maps or by the URP's MSAA effect. As a workaround you can disable the 'generate mip maps' toggle on your water textures. For the MSAA, you can use SMAA or FXAA instead on the camera component.

    More information here

    https://alexander-ameye.gitbook.io/stylized-water/support/troubleshooting#artifacts

    Thank you everybody for the continued support!
     
    fullerfusion likes this.
  23. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    163
    Hi @alexanderameye , sorry if this post is a duplicate :) I didn't check all in this thread. Just two feedbacks (including one bug) that I saw just after purchasing your asset.
    • If you had a Stylized Water asset in your scene and you've modified the settings in the Inspector, create a new one and see that it will inherit those parameters instead of having default settings.
    • That's how I saw the bug. Clicking on Reset to set back the params to default erases all the parameters : upload_2020-5-26_14-16-13.png
    By the way, this asset is so great and professional. Many thanks for that! Cheers!
     
  24. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    If you make a new water object by clicking GameObject > 3D Object > Stylized Water, that water will be initialized with the Ocean material by default and the material inspector will just copy over the current properties of that material. So if you already modified the Ocean material, the material inspector will start with those modified values.

    If you want to reset the material to its original form (how it was when you first imported the asset), then you should do it by selecting the material, and then in the inspector click on the little cogwheel on the top right and click Reset.



    So if you want to have 2 water objects that look differently, you will need to create 2 materials.

    Good catch on the reset button of the script! That should indeed not happen. I will fix this in the next update so that the reset button will reset the material to the default values. Currently I didn't implement any behavior for the reset button, but resetting the material to its default values is indeed the desired behavior here.Thank you for letting me know :)

    And thank you for the kind words, that means a lot. If you enjoy the asset, a review would always help me out greatly.
     
    MlleBun likes this.
  25. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey everybody! I've been gathering some of your feedback that I will use when working on the 1.1.0 update. If you have any more feedback or requests, please let me know!

    You can let me know on here on the forums, through mail or through discord.

    I'm very much looking forward to working on some updates for the shader :)
     
    fullerfusion likes this.
  26. markoal

    markoal

    Joined:
    Aug 31, 2015
    Posts:
    30
    Does this work for a lightweight render pipeline?
     
  27. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I only support URP starting from version 7.1.1

    If you import the asset in an LWRP project, you will get some console errors but of course since the shader is made with shader graph, it should work in LWRP as well. To get rid of the console errors you'll need to make some changes, but it's definitely possible.

    For the next update, when I'm adding support for HDRP I will also look into LWRP. Maybe I won't support it out of the box, but write a small guide on what to change so it will work with LWRP.

    The main things that I can think of right now that are URP specific and will give you errors are the support window, which you could remove from the asset if you wanted to since it's not a part of the shader, and then also the planar reflections script probably since it uses the universal render pipeline namespaces and I don't check for that currently.

    So to conclude, right now, you'll get console errors, but if you are willing to make some minor modifications, I think it should work, but no guarantees. For the next update I'll look into adding better support for LWRP.
     
    Last edited: Jun 2, 2020
  28. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    @markoal I did some tests and imported the asset into Unity 2019.2 with LWRP version 6.9.0

    It doesn't seem like it will be very easy to make this work with LWRP. When I try to open the shader graph in Unity 2019.2, the graph won't even open so it seems like the Unity team hasn't backported some features to LWRP, which makes the graph unusable in LWRP. I get the following errors.



    For the next update, I will be looking some more into this, but making the asset compatible with LWRP is not a priority at this time. If you want to use this asset, you'll need to upgrade to Unity 2019.3.
     
  29. markoal

    markoal

    Joined:
    Aug 31, 2015
    Posts:
    30
    @alexanderameye thank you for the test. Actually it's my bad, I used LWRP I didn't know it was replaced by URP in 2019.3 version of Unity. So I need to upgrade the project also where this asset should work.
     
    alexanderameye likes this.
  30. chillcarrier

    chillcarrier

    Joined:
    May 24, 2020
    Posts:
    4
    Hi and first off: thanks for that awesome tool!

    I'm also trying to achieve an infinite ocean type of solution but in a first person camera type game, which brought me here. So far I tried to avoid more than 4 separate tiles (performance wise, URP) and scaled each one up by the factor of 20 which does kind of work. It's just to get that island completely surrounded by water (maybe trying to move it with the character) and solving the rest with some fog in the distance.

    But yeah, just wanted to bring that feedback in.

    Best,
    Sebastian
     
    alexanderameye likes this.
  31. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I see Unity 2019.4 LTS was just released. I have not yet tested compatibility but there should not be any issues.



    In the next update, I will be adding support for URP/HDRP for Unity versions 2019.3, 2019.4 LTS and 2020.1
     
    chillcarrier and MlleBun like this.
  32. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hey Alex, do you have a plan to create water touch effect in the future?
     
  33. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    You mean like special effects on the water like splashes?
     
  34. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    yes,it is, so I can make effect like boat in the water ......
     
  35. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Yes for the next update I'm going to look into this, hopefully I can add some effects in that update, otherwise it will be for a later update, but I'll try to add some effects like splashes or boat trails.
     
  36. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    thanks Alex,very happy to hear that,it will give me lots of help with the water asset, best wishes to you
     
  37. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    Hey Alex,is there any way that this water can work with zwrite On transparency shader?
    I set my urp lit shader to transparency and turn on zwrite/ztest, then I cannot see the foam where model stick into the water.
     
  38. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    left is normal lit shader with cutoff/alpha cut, right one is what i said zwrite On transparency shader.
     

    Attached Files:

  39. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Could you check in the frame debugger if the character is writing to the depth texture?

    You can open the frame debugger by clicking Window > Analysis > Frame debugger

    In the window you'll see a depth pass, and you can see the depth texture there. Does the silhouette of the character show up there?
     
  40. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    upload_2020-6-18_21-16-51.png
    eh no silhouette here,I get the same effect with editor window if I do understand what you mean, I m not good at graphic,so this is my first time to open this frame debug window....
     
  41. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hmm, in the frame debugger I used to be able to see the depth texture nicely but now it doesn't show up for me, very weird.

    Anyways, you need to make sure your shader is writing to the depth texture for foam to show up.

    The "zwrite On transparency shader" you're using, what kind of shader is it? Are you able to share the code so I can take a look?
     
  42. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    Its really easy in URP, just set an obj's shader to urp lit shader,and then set to transparency mode.
    , then in the URP_Renderer asset add a new renderer feature. Give it a name, select the layer you want and check the box Depth, then Write Depth, and choose a Depth Test setting(LE).
    finally its a zwrite on ztest on transparency shader.
     
  43. Sibylline-Siren

    Sibylline-Siren

    Joined:
    Jul 8, 2012
    Posts:
    22
    Is it possible to have different instances of water with different appearance in the same project?
    I'm having trouble trying to do it but I'm unsure if it's just me.
    Example: ocean blue water in one place, muddy water in a pond, sewage in a sewer, etc.
     
  44. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    yes you can ,In my way is create new water material and drop to the new panel,finally add water component to the new panel.
     
    alexanderameye likes this.
  45. Sibylline-Siren

    Sibylline-Siren

    Joined:
    Jul 8, 2012
    Posts:
    22
    Not sure why it wasn't working but now it did, thanks a lot
     
    alexanderameye likes this.
  46. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I'm gonna test this out next week when I have some more time!
     
  47. bigbrainz

    bigbrainz

    Joined:
    Jul 21, 2015
    Posts:
    177
    Howdy. Just a data point that it's having an error in 2019.4.1 running 7.4.1. upload_2020-6-24_16-36-42.png
     
  48. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey! You can read more about that issue here. https://alexander-ameye.gitbook.io/stylized-water/support/troubleshooting#failed-to-open-source-file

    Basically sometimes, Unity messes up things on import. This might happen when updating your SRP version, your Unity version or the asset itself. You can fix this by re-importing the asset. You can do this by right clicking the Stylized Water For URP folder in your project window and clicking Reimport. This will probably fix the errors. Clear the console to check if the errors are gone.

    Please let me know if that worked!

    Also, what color space and graphics API are you using? The colors of the water looks a bit off.
     
  49. bigbrainz

    bigbrainz

    Joined:
    Jul 21, 2015
    Posts:
    177
    Worked like a charm, thanks!

    We're currently stuck on Gamma because we have some clients with crusty old systems that have to use Safari, which doesn't smoothly support WebGL 2.0 yet. (Curse you Safari!)

    But I switched over to Linear just to make sure that was the issue in the colors looking a bit off and they look just right in Linear:
    upload_2020-6-25_9-17-12.png
     
    alexanderameye likes this.
  50. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Aha! Yeah the asset was designed in linear and I don't officially support gamma, but other customers seem to be using gamma as well so I'll look into it and try to make sure everything works well there.

    Cheers,

    Alex