Search Unity

Stylized Water 2 [URP] ☑️ Desktop/Mobile/Consoles/VR

Discussion in 'Assets and Asset Store' started by StaggartCreations, Nov 3, 2020.

  1. tpaslou

    tpaslou

    Joined:
    Mar 30, 2018
    Posts:
    10
    Hi

    I got trouble making it work with Dynamic Water Physics 2. The script StylizedWaterDataProvider is a txt , so I changed it to .cs . Also the namespace where WaterDataProvider exists , is NWH.DWP2.WaterData. But I still cant make it work. What am I missing ?

    upload_2021-3-16_16-0-41.png
     
  2. tpaslou

    tpaslou

    Joined:
    Mar 30, 2018
    Posts:
    10
    Well for anyone that may find the same problem I fixed by adding this
    upload_2021-3-16_16-17-30.png
     
    ShodanIsAlive likes this.
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    A little unfortunate timing, since DWP2 was updated last week with added assemblies, so the integration failed to compile. Adding the WaterData assembly reference indeed fixes this, an update is already pending which adds this by default.
     
  4. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    206
    Heyo, seems there is a slight issue with the Enviro integration in the current asset store release. As soon as I tick the fog rendering to Enviro (2020.3 LTS, URP 10) I get this thrown at me and the water shaders turn pink:

    Code (CSharp):
    1. Shader error in 'Universal Render Pipeline/FX/Stylized Water 2': redefinition of 'ComputeDistance' at Assets/StylizedWater2/Shaders/Libraries/UnderwaterShading.hlsl(18) (on d3d11)
    2.  
    3. Compiling Fragment program with _UNDERWATER_ENABLED
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
    5. Disabled keywords: _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _SHADOWS_SOFT INSTANCING_ON _NORMALMAP _DISTANCE_NORMALS _WAVES _FOAM _UNLIT _TRANSLUCENCY _CAUSTICS _REFRACTION _ADVANCED_SHADING _FLAT_SHADING _SPECULARHIGHLIGHTS_OFF _ENVIRONMENTREFLECTIONS_OFF _RECEIVE_SHADOWS_OFF _DISABLE_DEPTH_TEX _SHARP_INERSECTION _SMOOTH_INTERSECTION _RIVER UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30
     
  5. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Thanks for the heads up! That's a little unfortunate accident, Enviro's fog code appears to have a function with the same name.

    You can open up the UnderwaterShading.hlsl file and replace any occurrence of ComputeDistance with ComputeDistanceX. Visual studio allows you to find and replace specific text through CTRL+F. I'll have to use a different name for the function moving forward :p
     
  6. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    206
    Worked like a charm, thank you for the instant reply <3
     
  7. steve_zeng

    steve_zeng

    Joined:
    Aug 6, 2019
    Posts:
    22
    I'm interested in the shader of the scene tree, and I don't mean the coconut tree.

    I think it's close to the scene tree effect in Genshi Impact games.

    Do you plan to sell a natural shader package that can be used on mobile?It is better to use the URP node diagram.
     
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    I used my grass shader on the trees, which worked well enough. SpeedTree shaders were pretty much broken in the URP version I recorded with.
     
  9. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    It includes a script to create a plane mesh for the spline. But the mesh's UV's stretch over the entire spline, and there's no further control over this. And it also flattens the mesh's normals, so the shader won't be able to tell which way the surface is pointing, so foam ends up drawing on the entire mesh (rather than only slopes). So technically, no, it's an example script and isn't fleshed out enough to support rivers.
     
    tahir_ali likes this.
  11. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Can you make something out of it for your asset. Like river creator type thing.
     
  12. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Not as of yet, waiting until Unity's native spline tool releases before deciding if and how to approach this.
     
  13. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    Does it work in WebGL 2.0 ?
    I saw in the desc you mentioned it supports OpenGLES 3.0
    so it should work
     
  14. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    I've just built the demo scene to a WebGL build and everything appears to work as it should!
     
    BAIZOR and Rallix like this.
  15. MRBAEK

    MRBAEK

    Joined:
    Sep 30, 2014
    Posts:
    13
    hi, i have a question.

    how can i make infinite ocean using lowpoly style?

    i have to try using ocean prefab and change material but it's not works.

    ocean prefabs are fixed "StylizedWater2_Ocean" material.

    so i try to WaterGrid component but when i change watergrid's scale, component show to me some error("vertex count of individual tiles is too high,.........).

    and i also try to change unity transform's scale, but wave element's size are too big.

    is there any solution?

    best regards.
     
  16. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    You can effectively enable the lowpoly look on any water material with the "flat shading" toggle.
    upload_2021-3-25_9-37-43.png
    But I recommend to just take the StylizedWater2_Lowpoly material, and tweak the wave settings so that it looks like an ocean.

    On the WaterGrid component, the rest of the error message is important: "Vertex count of individual tiles is too high. Increase the vertex distance, decrease the grid scale, or add more rows/columns". This refers to the parameters under the "Grid" header in the inspector. If the vertex distance value is too low, relatively to the scale of a tile, the mesh ends up with more than 65.000 vertices, which is the limit.
     
  17. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Your APK demo is nearly impossible to download from the android phone since it opens Onedrive and no way to install from there. Also, once installed, it goes SUPER SLOW. And my android is a pretty decent device. Right now I have a game with water (not yours), online, multiplayer and everything running at 60 fps. I install the stylized water apk and it doesn't pass 20 fps. And it´s only water!
     
  18. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    All I can say is that the performance you're seeing is contradictory to the benchmarks I've run on older and newer devices. I've recently enabled more features on the material, so its provides a more realistic idea about how it runs on older devices, rather than just blasting out 60fps on everything while looking rather basic.
     
  19. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Well, it´s your APK, if you got a better performance one please share. Or maybe allow features to be enabled/disabled on the apk. Also, I couldn´t see multiple angles on the demo.
     
  20. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    119
    Hey man have you checked your Shader on 2020.3 LTS because Sparkles are not working on my project. I deleted the whole folder and imported new one still no use. Kindly check!
     
  21. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Yes, 2020.3 will not pose any issues, mainly because the URP version hasn't changed.

    Sparkles requires the normal map feature to be enabled, and a directional light active in the scene. Without these, there is no information to work with to create them. For instance, in prefab inspection mode, you may not see them at all.
     
  22. tpaslou

    tpaslou

    Joined:
    Mar 30, 2018
    Posts:
    10
    There is a small problem with the Floating Transform component. My object is sinking slowly. This means that Y is slowly decreasing.
     
  23. lehrkommando

    lehrkommando

    Joined:
    Apr 2, 2021
    Posts:
    2
    I have a question while using for mobile URP.

    When I am using Camera Depth, how do I prevent certain layers (transparent objects such as Particles) from being calculated?
     
  24. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    This could be related to floating point precision errors, especially if the object is very far away from the world's center and it progressivly gets worse over time. There's little to be done about this unfortunately on my end.

    This isn't possible I'm afraid. The water uses the camera's depth texture as is, so it has no control over what was rendered into this texture or not. Transparent materials will never render into this texture, so the water's intersection effect won't affect these materials. So a dirty workaround is to use transparent materials on anything you don't want affected.
     
  25. noise_source

    noise_source

    Joined:
    May 4, 2015
    Posts:
    17
    WOW it looks amazing, I need a split over / underwater effect for my mobile game. It can be simple. Any chance it will work on ios?
     
  26. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Thanks! I haven't yet reached the point where I've tested anything on other platforms. But technically speaking there shouldn't be any reason why it wouldn't work specifically on mobiles.

    There is post-processing involved, which does incur a performance cost. Currently have blurring and screen waving implemented, but those for example could/should be disabled on the render feature, so could be enabled only on specific platforms.
     
  27. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    how customizable are the looks? Documentation doesnt cover this. like, If want to change the deep water colors or put my own foam texture.
     
  28. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Yes, you're right, could have used some elaboration! I've added a screenshot of all the shader parameters here now: http://staggart.xyz/unity/stylized-water-2/sws-2-docs/?section=shader
     
  29. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    Thanks! just what I was looking for!
     
  30. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    66
    I just have a question about underwater effects, are there any? Like setting the background to blue
     
  31. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Currently, no.

    A very basic way to reproduce this is to create a box volume (GameObject->Volume-> Box Volume), align it so that the top of the box matches the water level, then add any underwater-esque effects such as color grading. The result is these effects become active once the camera goes below the water level.

    You can set the water material to render as double-sided, so it doesn't appear invisible.


    But I'd recommend to duplicate the water plane, then rotate it 180, and assign a separate material to it so you can disable things like reflections or caustics for it.
     
  32. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    66
    Thank you very much. I have an another question, i could not find anything related on your documents page.
    I have objects, whitch could drop into the water, how to add to this objects some foam?
    You have something like on page 4.2 but how do i add this to dynamic objects?
     
  33. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Short version is that this isn't possible. But it can be somewhat faked by using the included particle effects instead (WaterRipples_Stationairy, for example)
     
  34. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    I just bought this asset along with the SC post processing and they are awesome. Question about the water shader... im using your fog post process effect and I'm wondering is there a way to have the fog completely cover the water transparency in the distance? would be perfect to have the terrain and water fade into the skybox perfectly.
     
  35. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Yes, this is certainly possible, hadn't considered the pairing. I've managed to get the integration working now. And I'm preparing an update for the package, so this'll be included along with it, some time early next week.

    Preemptive note: the "Skip Transparents" option must be enabled on the fog renderer, so that transparent materials are drawn over the fog. The water shader is this case would apply the fog locally and will match up 1:1 with the post-effect.


    For other transparent materials, see this post: https://forum.unity.com/threads/sc-...dditional-effects.513191/page-10#post-7065256
     
  36. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Submitted v1.0.9

    Added:
    - Support for SC Post Effects Pack fog rendering (activated through the Help window)

    Changed:
    - Material UI now has a help toggle button, with quick links to documentation
    - Buoyancy.SampleWaves function now has a boolean argument, to indicate if the material's wave parameters are being changed at runtime. Version without this has been marked as obsolete.
    - Floating Transform component now supports multi-selection

    Fixed:
    - Planar reflections failing to render if the water mesh was positioned further away than its size
    - Warning about obsolete API in Unity 2021.2+ due to URP changes, package will now import without any interruptions
    - Shader error when Enviro fog was enabled, due to a conflicting function name
     
    Acissathar likes this.
  37. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    wow awesome man thanks! and your stuff is great im loving it on my levels.
     
    StaggartCreations likes this.
  38. yborodajev

    yborodajev

    Joined:
    Jun 16, 2020
    Posts:
    19
    Its just for URP?
     
  39. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    As it says on the box :p
     
  40. Marco-Playable

    Marco-Playable

    Joined:
    Nov 12, 2020
    Posts:
    53
    Very nice asset!

    One problem I am having is that refraction & depth fog don't play nice with each other. Just refraction:
    upload_2021-5-11_15-43-40.png

    Refraction with color depth enabled:
    upload_2021-5-11_15-44-2.png

    Only solution I can think of is doing another depth pre-pass right before your shader is called and excluding the protruding geometry from _CameraDepthTexture. Or alternatively sample depth for the depth color based on refraction coordinates.
     
  41. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Thanks! Yes this is the case, it's kind of the lesser of two evils. Since also refracting the depth gradient makes the intersection effect stand out, creates discontinuities and objects above the water are also refracted. Things get more expensive to work around these artifacts, so I opted for the option that's cheaper and less noticeable during normal gameplay.

    Left is current, right is with refracted depth:

    upload_2021-5-12_9-5-50.png
     
    Marco-Playable likes this.
  42. Marco-Playable

    Marco-Playable

    Joined:
    Nov 12, 2020
    Posts:
    53
    Do you have recommendations on how to deal with the intersection of terrain and water plane? I had hoped the depth fade would take care of it, but there is a visible 1 pixel line where they intersect.
    upload_2021-5-19_17-24-57.png
     
  43. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    This is unfortunately unavoidable when using MSAA. Because MSAA only applies to the screen color, not the underlying depth texture (which the water relies on). You can see how the depth values are still aliased here, compared to the color:
    upload_2021-5-20_10-46-31.png

    So the only way around this is to use the AA options on the camera, instead of MSAA
     
    Marco-Playable likes this.
  44. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    I've been delving back into the underwater rendering extension these past few weeks, making some good progress!

    It wasn't visually hitting the mark, but that turns out because the fog was practically unlit, so stood out like a sore thumb. The directional light and ambient light now influence the fog color, so will be lit appropriately and works in dynamic lighting setups (the water line currently doesn't yet, so stands out)
    upload_2021-5-21_11-17-25.png
    upload_2021-5-21_11-18-15.png
    upload_2021-5-21_11-20-39.png
    upload_2021-5-21_11-21-13.png

    Translucency is also incorporated into the fog, so creates a nice faux-scattering effect

    An option to enable screen distortion and fog-based blurring also made it in (can be overridden on the render feature to disable them for lower quality levels)




    upload_2021-5-21_11-16-14.png

    Because the effect needs to render before transparent materials are, they won't be shaded by the fog. The reality unfortunately being that Unity's built-in shader won't support this if they are transparent.

    There's a SubGraph included to apply the underwater fog/mask to any transparent shader graph, so they blend in nicely. The sunshafts are also just particles, using the included underwater particle shader graph.



    Couple of things:
    • Import directly in the StylizedWater2 folder, into "Underwater" sub-folders, by all means an extension asset (price TBD)
    • Doesn't work at all in 2020.2+ right now, still have to figure out why
    • Directionally projected caustics will likely be possible in 2020.2+, so they won't show underneath objects. This requires the depth-normals texture, so performance impact varies per project. Works!
    • VR compatibility likely isn't in the cards
    • MSAA tends to show artifacts around the edges of objects underwater, a common limitation
    • Multi-camera and/or split screen is supported. Reflection probes capture the fog correctly, but not the water line
    • Stacked cameras will be looked into. The waterline will always draw over other objects, seeing as its right in front of the "lens" Won't work, effects won't render on any overlay geometry
    • Far too slow on mobile to be considered compatible (technically still works)
    • It's not a volumetric solution, mainly revolves around the use case of oceans or lakes. In any event, it requires a single water level, so inherently excludes rivers or spheres.
    • Fog parameters can be controlled through volume profiles (optional)
    • A few nit-picky artifacts when the camera sits directly on the water level. In a practical scenario, nobody will likely notice (in Ubisoft games its a lot more broken, so I'll take it)
    • Looks best when reflections and refractions are enabled on the water material
    • Using the combination of HDR, Tonemapping and the Gamma color-space will not guarantee the underwater fog matches the water perfectly. Otherwise seamless in Linear color space.
    • Still have to check if there will be any conflicts with third party fog effects (eg. Enviro or Azure). Technically, integration is very straightforward for them to do.
    • Rendering is only performed if the bottom of the screen touches, or is below the water. So doesn't have a performance cost for on-land gameplay. If a split-screen camera set up is used, it has to render constantly.
    • Water drops on the camera lens will be a potential subject for later
     
    Last edited: Jun 23, 2021
    LuiBroDood and Acissathar like this.
  45. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    Looks awesome, hope you get it working in 2020.3 soon
     
  46. madruytb

    madruytb

    Joined:
    May 10, 2018
    Posts:
    26
    Hey, I couldn't find anything in the docs, but my waves don't touch the beach like they should. How can I fix that?
    Attached an image which shows my game on the left and what I'm trying to achieve on the right.
    Wave height is set to 1 and it is behaving like that.
     

    Attached Files:

  47. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    Hey StaggartCreations
    I m following this asset for a long time,and I just want to know when it can reflection with orth camera?
     
  48. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    The wave height will be the same over the entire material. You can however use the blue vertex color channel to paint a flattening effect for the waves, so you can tone it down in specific areas. See the vertex color documentation section.

    This unfortunately won't be possible until URP gets Box Projection support for reflection probes, without it you'll see the reflection warping. This has already been merged into the master branch (link), so may be available in the 2021.2.0 release version. I'll need to make a few adjustments to the shader to add support for this.
     
  49. madruytb

    madruytb

    Joined:
    May 10, 2018
    Posts:
    26

    Got it! Is there any documentation on how to implement the water splashes/ripple when characters touch water?
     
  50. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    Submitted v1.1.0

    Added:
    - Diorama example scene
    - Exposed parameter to control the size of point/spot light specular reflections

    Changed:
    - Translucency shading will now also work if lighting is disabled
    - Intersection- and surface foam and now appear correct when using the Gamma color-space
    - Surface foam can now be painted using the Alpha channel of the painted color. Previously the Blue channel was used only if River Mode was enabled.

    - Planar Reflection Renderer component now shows a warning if reflection were globally disabled by an external script

    Fixed:
    - Scripting build error on tvOS due to VR code being stripped for the platform
    - When river mode is enabled, a second layer of foam on slopes wasn't visible.
    - Planar Reflection Renderer component needing to be toggled when using multiple instances
    - Buoyancy not being in sync when animation speed was higher than x1
     
    Last edited: Jun 14, 2021
    Acissathar likes this.