Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Stylized Water Shader - Desktop/Mobile/VR

Discussion in 'Assets and Asset Store' started by StaggartCreations, Sep 8, 2016.

  1. BlockFade

    BlockFade

    Joined:
    Jan 28, 2017
    Posts:
    24
    Hey! I REALLY love the style of this asset, and I just purchased it.
    However, I have a ideas to help make this asset better:
    Can you add support for set the Clear Flags for the Reflection Camera? I don't want it to reflect the clouds in my skybox, because real oceans don't reflect clouds.
    I also think you should add an option for the Intersection Style to be set to None, but the foam style still being able to use a different intersection style.
    Thanks!
    This asset is worth more than it's price!
     
  2. AltaVR

    AltaVR

    Joined:
    Oct 16, 2013
    Posts:
    8
    Hi Staggart,

    We just upgraded to Unity 2018 and believe we have encountered an issue exclusive to version 2.0:

    The intersection falloff no longer affects the "None" intersection style.

    StylizedWaterBug.png

    A fix for this or a solution to achieve the same affect as in the previous version would be sweet :)

    Thanks
     
    Leoo likes this.
  3. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    129
    Any chance to make it work in a 2D environment? without depth and stuff like that? just like an animated shader?
     
    DrOcto likes this.
  4. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    89
    *Update - the problem seems to be with the keep alpha fade. removing this fixes this problem. I have no idea what that does, or how this would effect other things in the shader so need to do some research perhaps this makes some sense to you?

    #pragma surface surf StandardCustomLighting alpha:fade keepalpha nodirlightmap vertex:vertexDataFunc

    Artifact or Z ordering Problem. Basically I can sometimes "see" through waves to other parts of the same mesh (this is a single mesh object). Not using the shader waves (waves set to 0) but deforming the mesh on the CPU side.

    Here is the problem shown in Artifact01

    Here is the same mesh shot from above so you can see what is on the other side in Artifact 02.

    I also turned off opacity completely just to see if I could block it and this still is happening which is odd so must be some sort of z order issue.

    //c.a = OpacityFinal814;
    c.a = 1;


    Artifact01.png Artifact02.png
     
    Last edited: Jul 24, 2018
  5. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    751
    Does this asset have underwater surface by any chance?

    Regards,
    Carlos
     
  6. BlockFade

    BlockFade

    Joined:
    Jan 28, 2017
    Posts:
    24
  7. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    272
    BTW: That method used to work well on an old version of the shader. It does not work well on the new one.
     
  8. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    751
    Ok, so it doesn't work any longer? and I was wondering also, if the reflection would work on the inverted water surface... Because I actually only need the underwater, since my game is only underwater.

    Regards,
    Carlos
     
  9. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    272
    Excuse me, I spoke prematurely. I've finally figured out what was causing the issue, and it does still work in the current version. You just have set Horizon Color Alpha to 0, otherwise upside down water will just be your Horizon Color.
     
  10. Alic

    Alic

    Joined:
    Aug 6, 2013
    Posts:
    109
    Hey Staggart, love this shader! It's really versatile and fun to play around with.

    Is there an approach with this can be used on rivers to get them flowing down a winding path? Some type of flow map support? Painting Vertex color? Or just modeling the UV's in a particular way? Thanks a lot for a great asset!
     
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Happy to hear it's to your liking :)

    If you set the Tiling method under the Surface tab to "Mesh UV", then set the X Direction to 0 and the Z Direction to 1 under the Waves tab, the water flow will follow the river. Though, the shader is not geared towards rivers, so there won't be any faster flowing water or foam on steep surfaces.
     
  12. jingray

    jingray

    Joined:
    Feb 6, 2015
    Posts:
    50
    Hi. Asset not working open gl 2.0 ? I tested on some device old Sony xperia E4, Oppo Neo 5, water not work and fps reduce very much on some device open gl 3.0.
     
    Last edited: Aug 24, 2018
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    The minimum requirement for mobile is OpenGL ES 3.0, any phone released after 2012 should support this. For instance, the Sony Experia E4 and Opp Neo 5 both have a ARM Mali-400 MP4 GPU, which stems from 2008, that is way to old to achieve reasonable framerates with modern graphics.

    Please have a look at this documentation section about mobile performance.
     
    Last edited: Aug 24, 2018
    jingray likes this.
  14. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Submitted version 2.0.1, which includes some minor fixes as well as the addition to set the water level for Vegetation Studio, so no vegetation is spawned below the water surface.
     
  15. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    72
    Thanks for the great plugin! But please help me understand how let me force to work it with an Ortographic camera?
    I mean that effect when water show intersection when camera is zooming.
    And maybe it's important: I'm using the mobile version.
     
    Last edited: Aug 29, 2018
  16. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    By zooming to you mean changing the orthographic size? Orthographic cameras only work with Forward rendering, when using this rendering path, the "EnableDepthBuffer" script must be added to the camera for the intersection and depth effects to render.
     
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Just submitted version 2.0.2 which fixes broken normals maps in Unity 2018.1+ when using Linear color space.
     
    rocky1138 likes this.
  18. rocky1138

    rocky1138

    Joined:
    Aug 13, 2012
    Posts:
    27
    We need some pictures and video of what it looks like in VR with reflections turned off, so that we know what we're buying (VR).
     
  19. naxovr

    naxovr

    Joined:
    Dec 8, 2017
    Posts:
    3
    Good Morning. First congratulate you for the work done with this asset.

    Some time ago one of the games did not update it and I wanted to add new functions, the fact is that when I open the project I get an error, even if I have updated your asset, and I can not fix it. If you could help me I would be grateful.

    I add a capture of the error that tells me.

    2018-09-16.png

    Regards, and thank you very much
     
  20. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    If you've updated from version 1 to version 2, you'll have to delete the old "StylizedWaterInspector" script. It was moved to another folder, so this created a duplicate script file. After which, the error wil clear ;)
     
  21. soundscouts

    soundscouts

    Joined:
    Apr 6, 2016
    Posts:
    3
    Greetings, I am also getting namespace / naming issues:

    "No monobehaviour scripts in the file, or their names do not match the file name"

    This is after deleting everything related to StylizedWater and reimporting several times. It works fine on an empty project, but for some reason I just cannot get it working on the existing one. I have combed through the project to find any kind of old reference or issue but found nothing.

    The only thing I have found is general recommendations not to name a class the same as its namespace, which StylizedWater.cs does,
     
  22. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    This sounds like it's caused by a serialization issue, you could try to set the serialization mode to "Force Binary" in the Editor Settings, then reimport it (you can switch the setting back after). If all fails, deleting the Library folder may work.

    I should probably change the namespace name, I didn't realize this was bad practice.
     
  23. DragonShadow

    DragonShadow

    Joined:
    Jun 27, 2015
    Posts:
    3
    Hello! I'll start by saying that this shader of yours is absolutely GORGEOUS. I was curious if you could clarify something for me. You mention that it does not support buoyancy; do you mean only that buoyancy isn't included in the package or is there something about the shader that would prevent other solutions (such as Realistic Water Physics or Advanced Buoyancy) from working with it? Thank you for your time!
     
  24. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Thank you! The package doesn't include any buoyancy functionality. If you were to add something like Realistic Water Physics, it would work as a flat plane, but the waves the water creates wouldn't effect any of the floating objects. This is because there is no way to read the wave height at a given point back to the CPU.

    I believe a few people have modified the shader to add Gerstner waves, and run the same Gerstner waves algorithm in parallel through script, with mirrored parameters (frequency, amplitude, etc). This allows to have virtual and visual waves to run in sync. So any height query by the buoyancy system would match the wave height you're seeing. Unfortunately this is not something I plan to implement, since I don't want to expand the scope to encompass water physics simulation.
     
    DragonShadow likes this.
  25. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    272
    I did the gerstner waves but never got around to implementing a cpu side copy of the code. Should be possible though.
     
    DragonShadow likes this.
  26. DragonShadow

    DragonShadow

    Joined:
    Jun 27, 2015
    Posts:
    3
    Cool, thank you for the reply and useful information.
     
  27. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Published this asset a wee two years ago! It was originally something intended for my Fantasy Adventure Environment package, but took a life of its own during development.

    It is now available for a 50% discount until October 8th. Thank you all for the ratings and reviews so far, they make a world of difference and help me to maintain and develop assets for the store :)

    https://www.assetstore.unity3d.com/en/?stay#!/content/71207
     
    Last edited: Sep 27, 2018
    happydayss likes this.
  28. happydayss

    happydayss

    Joined:
    Jun 13, 2017
    Posts:
    8
    Hello, love this asset and the look of it. I used it in one of my old projects and now I am doing a revision on the project, but am running into a with this error "Built-in support for Substance Designer materials has been removed from Unity. To continue using Substance Designer materials, you will need to install Allegorithmic's external importer from the Asset Store." I understand to install the asset but it has a lot of bad reviews and don't want to ruin my project. Do you know the problem and/or the solution. I also get the error "Assets/StylizedWaterBETA/StylizedWater_BETA.cs(928,9): error CS0246: The type or namespace name `SubstanceImporter' could not be found. Are you missing an assembly reference?" I deleted the old version and imported the new version but still get these errors. Version of Unity im using 2018.2.0f2
     
  29. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Hi, this is a pretty old version you're using. The Substance functionality was replaced to support 2018.1+ and the shader marked as "Beta" was revised and is now the default.

    The best course of action is to update the package to the latest version. At which point you may get an error about "StylizedWaterInspector", you can simply delete the (old) offending file.
     
  30. halDev

    halDev

    Joined:
    Apr 12, 2014
    Posts:
    55
    Hello, thinking of buying this awesome nice looking asset. I wonder does this asset have some of these effects.
    -Caustics
    -Wet sand effect of the shoreline
    -Fake small sparkling reflections

    Saw the clip where they talk about the RIME water VFX starts at 13:00 and was wondering if this asset have some of those features?



    /Cheers
     
  31. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    It doesn't include caustics or wet shores, the sparkles in the RiME shader are a fairly specific implementation. This stylized water shader has a glossiness slider, at about 90% glossiness, specular sun highlights will start to show.
     
  32. halDev

    halDev

    Joined:
    Apr 12, 2014
    Posts:
    55
    Ok thanks for the anwser. Wet shores and caustics would be a nice feature for this asset. Hope that maybe they will be implemented in the future :)
     
    naxovr likes this.
  33. naxovr

    naxovr

    Joined:
    Dec 8, 2017
    Posts:
    3
    Sorry for not having answered you before.

    It works perfectly as you said to do. You are a crack!
     
  34. Kreep

    Kreep

    Joined:
    Aug 1, 2013
    Posts:
    9
    Hi,

    I have a problem with the mobile shader. On desktop, it looks like this :

    upload_2018-11-12_18-12-18.png

    But if I put the settings in Low or Very Low on PC build platform or when I switch to Android build platform on the editor, the intersection acts weird (no intersection at the edge and a transparent edge depending where the camera is looking. The problem remains in Android builds on my phone.

    upload_2018-11-12_18-14-34.png

    I tried a lot of things but I don't understand what is the problem.

    EDIT : My Unity version is 2018.3.0b8
     
    Last edited: Nov 13, 2018
  35. raphafortin

    raphafortin

    Joined:
    Jul 27, 2013
    Posts:
    6
    Hey there! The shader does not render on mobile. The plane disapears. any idea? Thanks
     
  36. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    I'll have to test this out, it may very well an issue attributed to the beta version. Off the bat, it looks like the depth buffer is acting up. Strangely enough, quality settings shouldn't affect the depth buffer.

    I assume you're using the default quality levels?


    When a shader turns invisible, it unfortunately doesn't clearly indicate the cause of the issue. It may be related to the device you're using (must be newer than 2012 and support GLES 3.0). If it manages to fail on any device, it could be related to your project or scene. You can find out by building one of the demo scenes included in the package. If it works there (or doesn't), I'll know more and we can move forward from there :)
     
  37. raphafortin

    raphafortin

    Joined:
    Jul 27, 2013
    Posts:
    6
    I found the problem actually. When I use Post process Stack from Unity, the water shader does not render on the build. Is there a workaround? I'm in deferred lighting with Bloom and FOG on the Post Process camera.

    I think the fog might be the culprit.

    Thanks

     
  38. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Just ran a number of builds in 2018.3b8 using the Post Processing Stack v1 and v2, on Very Low and Ultra, but I cannot reproduce the same issue. Does it work for you when building one of the demo scenes?

    In any case, you can try to enable the "Use 32-bit Display Buffer" option in the Player Settings for Android.
     
  39. raphafortin

    raphafortin

    Joined:
    Jul 27, 2013
    Posts:
    6
    I mean, it is the fog in the deferred rendering mode. Even using your demo scene. Have you tried running a build in deferred with the fog on?

    Im in 2018.2f using PPS v2 and nothing else.

    Thanks


     
  40. raphafortin

    raphafortin

    Joined:
    Jul 27, 2013
    Posts:
    6
  41. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    I built using Deferred rendering with the fog settings enabled on the PostProcessLayer and in the Lighting settings.

    Please DM me a zip file of your ProjectSettings folder, so I can build using the same settings.
     
  42. Mathieu

    Mathieu

    Joined:
    Jun 13, 2005
    Posts:
    101
    Hello,

    Do you have plan to support Unity 2018.3?
    Do I have a way to force the installation and is it a bad idea? :)
     
  43. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Very close to it! There's just a pesky bug on Android (specifically OpenGL) that I can't seem to fix. But everything else seems to work without any issues on desktop. Hence no official "compatible" label yet ;)
     
    DragonShadow and MaximilianPs like this.
  44. Acissathar

    Acissathar

    Joined:
    Jun 24, 2011
    Posts:
    479
    Is there a recommended way to have the waves move back and forth? For example, I'm guessing I could set a timer and every X seconds shift the XZ direction to the opposite in the script, but wasn't sure if there was a "better" way already set up with the shader.
     
  45. incendy

    incendy

    Joined:
    Aug 23, 2013
    Posts:
    5
    Love the asset but was wondering why it cuts off all my 2d Sprites? They are only visible if the water is not in the background. Hoping I can use this asset, but seeing my sprites and UI is important for me. Is there a fix for this?
     
  46. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    Apparently yes, the material properties for the waves can be set using a sin wave. I believe this script will achieve the results you are after:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class RockingWaves : MonoBehaviour
    6. {
    7.     public Material mat;
    8.  
    9.     [Space]
    10.  
    11.     public float speed = 10f;
    12.     public float length = 0.1f;
    13.  
    14.     [Header("Direction")]
    15.     [Range(0f, 1f)]
    16.     public float xAmount = 0f;
    17.     [Range(0f, 1f)]
    18.     public float zAmount = 1f;
    19.  
    20.     private void OnEnable()
    21.     {
    22.         if (!mat) return;
    23.  
    24.         mat.SetFloat("_Wavesspeed", 0.01f);
    25.     }
    26.  
    27.     void Update()
    28.     {
    29.         if (!mat) return;
    30.  
    31.         float sin = Mathf.Sin(Time.fixedTime * (speed * 0.1f)) * length;
    32.  
    33.         mat.SetVector("_WaveDirection", new Vector4(sin * xAmount, 0f, sin * zAmount, 0f));
    34.     }
    35. }
    It will only work in play mode, since the StylizedWater inspector already sets the material properties in the editor, creating a conflict.

    Sprites, or at least their shader, generally don't write to the depth buffer. Since sprites are sorted among themselves using their Sorting Layer, whereas 3D geometry uses pixel depth and their material's render queue.

    If you want to combine 2D elements, such as sprites, with 3D geometry, the sprites must also write to the depth buffer, so they can be sorted. Shaders such as the UI and Unlit shader do not do this by default. I recommend to try this sprite shader, which also has depth writing option: https://assetstore.unity.com/packages/vfx/shaders/uber-shader-for-sprites-88191
     
    Acissathar likes this.
  47. marcmantraunity

    marcmantraunity

    Joined:
    May 31, 2014
    Posts:
    16
    Hi @StaggartCreations

    I'm working using the Stylized Water on our open environment. I detect something I don't know if we have to change something or it's an issue.
    If we create a heat effect, using Particles/Standard Unlit, the particle hide the water behind it.

    upload_2019-1-17_12-31-47.png

    upload_2019-1-17_12-32-51.png
     
  48. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    This seems to be a sorting issue between transparent materials. Worth trying to change the render queue on the water material. You'll have to comment out the "material.shader = shader;" line in the StylizedWater script (last line of the SetShaderType function). To avoid it being reset to default.
     
  49. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    148
    Hey there,
    I want to use this water shader for my tile based game. Just I want to know if it is possible and if it is, can I concatenate next to each other water tiles ?
     
  50. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    830
    It's not entirely suitable for usage with water tiles, this is noted in the store description. Primarily because of planar reflections, which will render for every tile, rapidly slowing down performance. If you don't plan on using realtime reflections then it won't be a problem.