Search Unity

Feedback Stylized Water Shader (FREE!)

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

  1. Deleted User

    Deleted User

    Guest

  2. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    In a next update I'll be adding support for multiple lights!



    Since I'm doing calculations for extra lights, this might have an effect on performance so in the lighting settings you'll be able to switch between Unlit, Basic Lit and Advanced Lit. To toggle these effects. Have a nice weekend everybody!
     
    fullerfusion and Lars-Steenhoff like this.
  3. fullerfusion

    fullerfusion

    Joined:
    Dec 2, 2018
    Posts:
    22
    Hi alexander,
    I imported the new update, version 1.02 of the Water Shader. Once it finished importing I got thrown a lot of errors about it "failed to open source file: 'Assets/Stylized Water For URP/Shaders/Subgraphs/StylizedWaterForURP.hlsl' and several others. Here are some screenshots of the error messages

    Screen Shot 2020-04-19 at 8.17.57 AM.png

    Screen Shot 2020-04-19 at 8.22.10 AM.png
    Screen Shot 2020-04-19 at 8.22.10 AM.png
    Screen Shot 2020-04-19 at 8.26.36 AM.png
    As a result, it turned the water shader to pink in the scene Screen Shot 2020-04-19 at 8.20.28 AM.png

    I'm not sure what I did wrong? I just simply imported the new update and bam errors. Got any suggestions as to why I'm receiving errors on the StylizedWaterForURP.hlsl?
     

    Attached Files:

  4. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Could you try right clicking on the Stylized Water For URP folder in your project view and re-importing it? That might fix the errors.
     
    nikatwork0099 and fullerfusion like this.
  5. fullerfusion

    fullerfusion

    Joined:
    Dec 2, 2018
    Posts:
    22
    Yep, that fixed it. Strange why that happened though. Oh well ‍¯\_(ツ)_/¯ Thanks for your quick response!!!
     
    Last edited: Apr 19, 2020
  6. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Yeah, another user had the same issue when updating their URP version or when updating Unity. As far as I know this is a bug on Unity's side. I've had errors like this in the past when moving around folders in the project folder as well. Very strange indeed. I'll keep on the lookout to see if this will be fixed in future URP versions! Thankfully the errors are harmless and the fix is easy :)

    I added a section about this on the troubleshooting page. https://alexander-ameye.gitbook.io/...rt/troubleshooting#failed-to-open-source-file

    Thanks for letting me know!

    Alex
     
    Sky_Higher and fullerfusion like this.
  7. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Recorded a video showing the point light support a bit better!

     
    Deleted User likes this.
  8. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I created a Discord server in order to help users more easily with support. I prefer this method over email or something else, because the interaction is much faster.

    You can join the server here if you have any support needs. https://discord.gg/6QQ5JCc

    Enjoy the weekend!

    Alex
     
    Last edited: Apr 27, 2020
  9. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    cannot open the discord in china. .
    still work great for my project.

    hoping for new update in road map.
     
  10. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Updated the link! It should work now.
     
  11. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hello Alex!
    its still work very very well in my project but without a problem. it seems that whatever how i set the light , i can not get the night effect with your water. its still light in the night..
     
  12. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    The water material is unlit and so the colors will not change when you turn off the light. For now I do not want to change this, but in the next update I will make it so the water colors react to lights so that your water will look good when it's night in your scene.

    For now what you could do is change the master node from unlit to PBR. In the shader, create a new master node called PBR Master. Connect the nodes as follows.



    Then right click on the PBR master node and click 'Set Active'. The shader will re-compile and your water will react to the light. Be sure to use a metallicness and smoothness of around 0.1 and to set the surface type to transparent on the master node!

    I'll add better options for this in the next update so your water will react do day/night!
     
    chillcarrier likes this.
  13. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    THANKS MY FRIEND FOR YOUR REPLY!!! i m very appreciate!
    I m so confused why such a wonderful asset dont get enough people's attention
    best wishes to you !
     
  14. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I'm already super happy with how well the asset was received. Makes me proud :)
     
  15. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    A customer asked me about spherical water meshes. At the moment, the shader will only work on planar meshes! I added a note about this in the limitations section of the manual so there is full transparency about what this shader is able to achieve. https://alexander-ameye.gitbook.io/stylized-water-for-urp/support/limitations

    In the next update I will add a toggle to switch between world space and mesh UVs and I will look into adding support for non-planar meshes like spheres and cubes. Have a nice weekend!
     
  16. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Coming in the next update, support for HDRP!



    You will be able to choose between 3 shader variants.
    • URP mobile
    • URP desktop
    • HDRP
     
    Lars-Steenhoff likes this.
  17. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    very happy to hear that,if that i will move to hdrp either for the point light's realtime shadow
     
  18. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Nice! I'm excited to explore what HDRP has to offer as well. I might be able to create some better looking effects in the HDRP variant targetting more high end devices.
     
  19. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hey my friend ,stupid question here, anyway I can get a effect that donot show the depth thing in the water .
    i don't know if you understand, i mean cannot see the obj in a deep position under water
     
  20. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    and another question, why we have a public setting for the water. just now i create a new scene for test and create a water then i modify the settings, but when i back to my main scene ,god everything changed,.,,,,
    sorry for the stupid questions my friend
    best wishes to you
     
  21. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey, do you mean that there are objects positioned underwater that you can not see?

    First, make sure that the opaque texture is being generated. Then you can set the transparency of the water by modifying the alpha components of the water colors.



    The picture is above with transparency turned off. Alpha components of 255.

    As you can see the water is fully opaque.



    By changing the alpha components you can add transparency.





    So if you want objects underwater to remain invisible, use a high alpha value for the deep water color so that the deep parts of your water are fully opaque.
     
    Last edited: May 4, 2020
  22. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    If you want to have 2 bodies of water that have different visuals, you need to create 2 water materials. When you use a water material in 1 scene, then modify the same water material in a 2nd scene, the water in scene 1 will have changed as well.

    To create a new water material, create a material in your project folder and set the shader type to the Stylized Water For URP type.



    Then when you add the material to an object, I recommend you to add the StylizedWaterForURP script as well to the object, so you have a nice material editor for it.

    If you want to use the ocean material that came with the asset, you can always reset the values to the default properties that came with the asset.



    To do this, select the material, and click on the little cog icon and then Reset.
     
  23. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    thanks myfriend , you solved all my problems.
     
    alexanderameye likes this.
  24. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    New release: 1.0.3

    Added
    • Added the option to modulate wave steepness through vertex colors (B channel)
    Fixed
    • The direction sliders can now perform a full 360° rotation
    • Improved the location of the shader subgraph files
    The update was just submitted for review and should be live soon. Here is a video showcasing the new feature that allows you to 'paint' the wave height on a per-vertex basis through the blue channel of the vertex colors.



    In order to paint vertex colors, you can use Unity's Polybrush package.

    Have a great week everybody!
     
  25. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hello Alex,
    i found a new problem with camera in orthographic mode,
    plase look at the picture,the water show strange rim of the front obj.
     

    Attached Files:

  26. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I will look into this! Does turning off the refraction fix the issue?
     
  27. jykholodia

    jykholodia

    Joined:
    Aug 29, 2018
    Posts:
    13
    Hi Alex,
    I'm very interested in your asset, but was wondering a few things regarding the mobile variant, especially the refraction. Would you be able to enable it at some point for mobile? The water we're currently using has refraction on mobile, and doesn't seem to impact performance too much.
    Maybe what I'm asking is, can the desktop variant be used on mobile?
     
  28. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hello, thank you for the interest.

    The biggest impact on mobile performance seems to be the lighting effects, so if you turn those off, the shader should already be a lot more performant. Of course it also depends on how prominent the water is in your game. In the demo scene I made the water take up all the pixels of the screen, because this is the worst-case scenario, but in your game if the water is just a part of the scene and doesn't take up all of the pixels, performance should be better as well.

    The reason that refraction is disabled for mobile devices is that for refraction to occur, a 'grab pass' has to occur first. In a grab pass, the 'camera opaque texture' has to be generated by the pipeline. This is extra overhead.

    Since you asked, I added refraction to the mobile variant and tested the performance on my mobile device. I found that the grabpass did have an impact of a few frames per second. I will investigate this further and I might add refraction to the mobile variant in a future update, but it really depends. I really want to make the mobile variant perform well, that's the top priority.

    The conclusion is this. If you do decide to purchase the asset, you can contact me and I will provide you with a mobile variant that includes refraction so that you can use refraction in your project. This will probably have a bit of impact on performance, depending on your project and the role that the water plays in it.

    If you have more questions, please ask.
     
  29. jykholodia

    jykholodia

    Joined:
    Aug 29, 2018
    Posts:
    13
    Thanks a lot for your prompt & exhaustive response, as well as testing! I guess we'll actually use the desktop version, since we already need the opaque texture anyway.
    I'll most likely purchase & try it in the coming days, and let you know.
    Cheers
     
    alexanderameye likes this.
  30. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hello alex
    Shader error in 'Shader Graphs/Stylized Water For URP Desktop': failed to open source file: 'Assets/Stylized Water For URP/Shaders/Subgraphs/StylizedWaterForURP.hlsl' at line 253 (on d3d11)
    Shader error in 'Shader Graphs/Stylized Water For URP Desktop': failed to open source file: 'Assets/Stylized Water For URP/Shaders/Subgraphs/StylizedWaterForURP.hlsl' at line 2110 (on d3d11)
    two errors show after i update to urp7.21
     
  31. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Right click the Stylized Water For URP folder and click on reimport. That should fix it.

    More information here. https://alexander-ameye.gitbook.io/stylized-water/support/troubleshooting#failed-to-open-source-file
     
  32. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Played around with clayxels today together with some bright and playful colors.

     
  33. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
  34. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    Hello Alexander,

    First I'd like to say that I am very happy with your asset, well documented, works out of the box, and very neat files and folders organisation (this became rare in the store...).

    I'm trying to create waterfalls all around a circular water, but my particles are always behind :/ do you know how can I fix this?

    waterfall.png

    Thanks!

    Erdal
     
  35. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hey my friend , bug reports.

    Screen position out of view frustum (screen pos 0.000000, 0.000000, 32359.824219) (Camera rect 0 0 1407 643)
    UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera(ScriptableRenderContext, Camera)
    StylizedWaterForURP.StylizedWaterURP:ExecutePlanarReflections(ScriptableRenderContext, Camera) (at Assets/Plugins/Stylized Water For URP/Scripts/Runtime/StylizedWaterURP.cs:350)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    it will show when i m in editor mode and try to rotate sceneview camera
     
  36. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    You can find more information about this error in the troubleshooting section of the manual.

    https://alexander-ameye.gitbook.io/...ing#screen-position-out-of-view-frustum-error

    Does the error occur when you are zoomed out really far?

    I submitted an update to the store with a possible fix. It got rid of the errors in my own project, but it could be that this won't work in your project. I'm continuing to investigate and will let you know when it is fixed :)

    If you want to get rid of the error, you could do things like disable/enable planar reflections or close the scene view window and then reopen it through the Window > General > Scene menu.

    My apologies for this issue. The reality is that I'm kind of guessing in the dark here, I'm having a hard time figuring out what exactly is causing this issue. I submitted an update which implements several possible fixes, and the fixes work for me, but you might encounter other cases that trigger the error.
     
    Last edited: May 13, 2020
  37. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Hey, thank you for the kind words.

    I tried recreating this but I'm not able to reproduce the issue. Is the water in your scene a circular mesh and then a cylinder below it? Is this using the mobile or desktop shader variant? And could you maybe share the material you use for the particles?

    This is the result in my project.

     
  38. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    Thanks for the super quick reply!!

    Indeed it was exactly what you did (except that I've put the resulting material also on the cylinder but I don't think it has to do with that).

    I will try to reproduce in a small project, that's weird o_O
     
  39. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    I am using Android platform.

    I just did reproduce in your demo example (here particles are always in front, even when inside the water, as you can see) :

    errrrr.png

    And I think it's also actually visible in your test above, it's just that particles in your test are always in front of the water.

    (depending on the material you choose for particles, it's either always in front or always in back of the water, don't know why).

    I cannot use opaque cylinder as a workaround for my specific "waterfall" need because it will make the floor visible:

    errUntitled.png

    Do you have any idea how I can make particles depth work?

    Thanks :)
     
  40. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I'll investigate and get back to you!
     
  41. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    Thanks!

    Just tried with desktop platforms btw but it doesn't change anything
     
  42. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Alright @Erdal42 so I did some testing and found out the following things. I made a particle ring around my water object like in your example.



    As you can see the particles that should be occluded by the water mesh, are drawn on top. This makes sense since the mobile shader variant is transparent.

    Then I tried setting the 'order in layer' of the particle system to -1 with the following result.



    As you can see this has the problem of occluding the particles on the front side.

    Then I tried adjusting the render queue of the shader. With a render queue of 3050 I get the following result, still not good.



    I believe you can solve your problem by using a cutout shader for your particles. Using the following shader Unlit>Transparent Cutout I get the following result. You could of course modify this built-in cutout shader to satisfy your particle shader needs!






    The above result seems correct to me.

    Another thing you could do that seems to fix issue for me is just make the water opaque. You can do this in the shadergraph file on the master node. Since the opaque water will write to the depth buffer, the necessary depth sorting can be done which can't be done with a transparent water shader since a transparent shader doesn't write to the depth buffer.



    That gives me the following result.



    Which looks good to me as well. Of course making the mobile shader variant opaque, has the downside that well, the water will be opaque! The desktop shader does a grab pass to fake transparency but for performance considerations, this is not done for the mobile variant at this time. Modifying the mobile shader variant to do a grab pass and have fake transparency (like the desktop shader) is of course a possibility.

    Personally, I think a cutout shader is the best option.

    Does this help you with your issue?
     
  43. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    Thanks for your possible solutions,

    I also checked and it appears that the probleme always appear when the particles and the water is transparent.
    That's a bummer as I wanted the both to smoothly blend :/

    Regarding the solutions:
    1. Cutout (and more generally opaque FX): well that makes the FX opaque, but it may work when I will put the actual water texture on those particules.

    2. Opaque water: that's not possible as I have floating animals on the game, which renders perfectly with the transparent water, I really want to keep this :)

    3. Desktop shader: I didn't really understand all here, but I tried compiling in desktop platform and I still have the same bug?

    Maybe the third point can give the desired results, can you explain a little bit more about this?

    Meanwhile I will also try some other workaround like an opaque half cylinder on camera front
     
  44. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I misspoke about the desktop shader variant. It's also a transparent shader (not opaque), it just doesn't use the alpha channel but uses a grab pass to fake transparency instead of the mobile shader variant, which uses the alpha channel for transparency.

    And it might be worth looking around online for some solutions, since this issue is not specific to my water shader, but a general issue related to depth ordering between particles and transparent objects.

    For example this thread mentioned cutout shaders.

    https://answers.unity.com/questions/609021/how-to-fix-transparent-rendering-problem.html

    I'll try to do some more research online and see what I can find. You might be able to fix some things by adjusting the rendering queue of the particle shaders. You can do this by setting the inspector to debug mode. Let me know if you find a workaround :)

    Edit: Another article here that might provide some insights. https://realtimevfx.com/t/transparency-issues-in-unity/4337/2
     
  45. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    Thank you very much for your detailed answer! Once I understood the issue, the workaround was very quick :)

    doed.png

    I've just split the circle shape Fx into two circle shape Fx (but with 180 degres arcs + layer sorting) hehe :D
     
  46. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Ooh, I like this solution! I'm going to post some information about these sorting issues in the troubleshooting section of the manual. Thank you for reaching out about the issue! If you enjoy the asset, a review would always help me out greatly :)

    I also wanted to ask if you happen to have a twitter account related to your gamedev activities. I'd love to follow development if you are making a game. Have a nice week!
     
  47. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    Done! ;)

    Not yet, it's my first mass market game (just done B2B Hyper-reality games before), but I like the idea! I will do post :) https://twitter.com/gunyar

    Have a nice week too!
     
    alexanderameye likes this.
  48. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hey alex, work very well until now,hope for your new update!
     

    Attached Files:

  49. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    Hi there,

    I am building my project for android, but I don't get what I have to do to get the water rendering correctly on mobile platforms. The desktop version looks peachy, but the mobile version shows white textures (it looks like the desktop version is looking if opaque textures aren't enabled). What do I have to switch/enable? Or what else am I doing wrong?

    Cheers,
    Volkerror
     
  50. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Is this with OpenGLES or Vulkan?

    There is a known issue/limitation on OpenGLES3 related to surface foam.

    https://alexander-ameye.gitbook.io/stylized-water/support/limitations

    Do you maybe have a picture of how it looks on desktop vs mobile? I'll investigate this for the next update and see if I can fix it.