[RELEASED] Game 2D Water Kit

:slight_smile: Version 1.4.8 is out!! :slight_smile:

Game 2D Water Kit allows you to create fast, dynamic, and nice-looking 2D water and waterfalls.

Supported Render Pipelines:

:white_check_mark: Standard (Default) Render Pipeline (Unity 2018.4 or newer)
:white_check_mark: Lightweight Render Pipeline - LWRP 6.7 or higher, 2D Renderer (Unity 2019.2)
:white_check_mark: Universal Render Pipeline - URP, 2D Renderer (Unity 2019.3 or newer)

:zap: Key Features:

  • Highly customizable water and waterfall systems

  • Top performance across platforms - Mobile friendly

  • Well-integrated into the Unity Editor with clean and well-organized inspectors

  • Quickly tweak and test the water and the waterfall simulation properties in edit-mode

  • Seamless integration into the Sprite workflow:

  • Easily sort the water/waterfall object relative to sprites using sorting layers

  • Hide or reveal parts of the water/waterfall object using Sprite Masks and Mesh Masks

Water System:

  • Optimized real-time refraction and reflection effects

  • Dynamic waves with 4 different types of ripples:

  • On-Collision Ripples:

  • Created when a rigidbody falls into the water

  • Created when a rigidbody gets out of water

  • Created when a rigidbody moves in water

  • Constant Ripples: Created at regular time intervals

  • Script-Generated Ripples: Created in code

  • Waterfall Ripples: Created by a waterfall object that overlaps the water object

  • Sine waves

  • Waves Can Affect Rigidbodies: Rigidbodies floating on water follow the undulations of water waves

  • Customizable sound and particle effects for each type of ripple (excluding the waterfall ripples), with an efficient object pooling system

  • Easily create very large (limited to a specific region) or endless water areas with great performance

  • Fake perspective effect: Add a sense of depth to your scene by rendering certain objects as partially submerged into water

  • Set a solid or gradient color, a texture, or even a texture sheet animation and apply distortion effects, across the water body and/or surface

  • Animate the water size either in code, or using Unity animation system

  • 8 optimized water shaders:

  • 4 shaders for the Builtin Render Pipeline: 1 unlit, and 3 lit shaders (pixel-lit, vertex-lit, and vertex-lit-only-directional-lights)

  • 2 shaders for the Lightweight Render Pipeline: 1 unlit and 1 lit shader (supports the 2D Renderer)

  • 2 shaders for the Universal Render Pipeline: 1 unlit and 1 lit shader (supports the 2D Renderer)

Waterfall System:

  • Optimized real-time refraction effect

  • Can interact with water systems it overlaps, disturbing their surfaces and creating ripples

  • Set a solid or gradient color, a texture, or even a texture sheet animation and apply distortion effects, across the waterfall body, left-right edges, and top-bottom edges

  • 8 optimized waterfall shaders:

  • 4 shaders for the Builtin Render Pipeline: 1 unlit, and 3 lit shaders (pixel-lit, vertex-lit, and vertex-lit-only-directional-lights)

  • 2 shaders for the Lightweight Render Pipeline: 1 unlit and 1 lit shader (supports the 2D Renderer)

  • 2 shaders for the Universal Render Pipeline: 1 unlit and 1 lit shader (supports the 2D Renderer)

For more information, please check:

Asset Store Page

Looks great! I’m thinking of grabbing this but I have a few questions…

  1. What’s the purpose of the Prefab Utility you mention in the documentation? Does this plugin support Unity’s standard prefab workflow as default too, or do you have to use the Prefab Utility?

  2. How does this plugin play with Unity’s own Pixel Perfect package? I could imagine that depending which one takes precedence, reflections and refraction might look a bit weird and distort low-res pixel artwork quite heavily. Any observations there?

Thanks! :slight_smile:

1- The plugin uses Unity’s standard prefab workflow. Prefab Utility just makes sure that the prefab is saved properly.
When you first create the water object in your scene, the water script will create a new material to be used by the water’s MeshRenderer and a noise texture to be used by the newly created material. This material and the noise texture are not saved as assets in your project yet, they belong to the scene and get serialized with that scene.
So, if you simply drag and drop the water object from the hierarchy to the project view, Unity will create a prefab but it will not save the material with it, and the prefab will end up with a missing material!
To get around this issue, Prefab Utility will take care of saving the material and its noise texture in your project first, then it will create the prefab.
You just need to specify where you want to save the prefab, press the “Create Prefab” button and done! :smile:

2- The plugin was tested with Unity’s own Pixel Perfect package, and it works just fine! :smile:

1 Like

Hi there, first of all thanks for the assets! The water effects look great and I’m having great fun with all features. I’m fairly new to Unity and am looking to do a couple of things with C# scripts:

  • how do you change the color of the Game2d water material? The attached script works when attached to sprites but I can’t figure out how to adapt it to the water material.
  • how would you change the liquid depth? E.g. push a button and liquid depth goes up, push another it goes down

Any help much appreciated :slight_smile:

3867715–328135–ColourChange.cs (297 Bytes)

1 Like

Hello!
Thank you so much! I’m so glad you’re having fun with the asset ^^

[EDIT]
As of version 1.3, it’s now much easier to change the water colour at runtime. I have attached an updated version of the script.

1- I adapted the script so it should work now with the water material too, and it sets a random colour each time you press the R key! If anything still unclear, please let me know :slight_smile:

(Sorry for the bad gif quality)

[EDIT]
2- As of version 1.3, you can use the method
.AnimationModule.AnimateWaterSize(targetSize,duration,constraint,wrapMode)

  • targetSize: [Vector2]: sets the water target size.

  • duration: [float]: sets the animation duration in seconds.

  • constraint: [enum WaterAnimationConstraint]: constraints the position of one/multiple water edge(s).

  • None, Top, Bottom, Left, Right, TopLeft, TopRight, BottomLeft, BottomRight

  • wrapMode: [enum WaterAnimationWrapMode]:

  • Once: Stops playing the animation once the target size is reached.

  • Loop: The water size is reset to the initial size and the animation is restarted once the target size is reached.

  • PingPong: When the target size is reached, the initial size will be the new target size. So the water size will ping-pong back and forth between the initial and the target size.

For more information please check https://game2dwaterkit.haydeludos.com/water-system/water-size-animation/
[ORIGINAL REPLY]
2- A straightforward solution would be to use Unity Animation system. So you could create two animation clips to animate the water size (here you just need to change the water height (y value)): one animation clip for increasing the water depth(height) and one for decreasing it. Then, you control which of the two animations to play inside your script depending on the pressed key. The water script will then detect the change to the water size and will update accordingly.
But, there’s a better and more flexible solution to the problem IMO that will avoid the hassle of creating the animation clips and managing the controller(animation controller) animations states. We could implement a new public method inside the water script that gets the target depth (and maybe another parameter to set the animation speed (how fast we reach the target depth)), and then we update the water size inside the water script’s update method each frame until the target depth is reached. Then inside your script, you just need to reference the water object and then call the new method with the proper target depth depending on the pressed button. Please feel free to contact me (please check the contact page on my website) so I could provide you with the steps to set up the first solution, or the necessary changes to the water script if you’de like to implement the second solution.

(Implemented the second solution here)

Please let me know if anything is still unclear :slight_smile:

3868015–356329–ColourChange.cs (1.69 KB)
3868015–380134–[Updated] ColourChange.cs (1.21 KB)

1 Like

Hi, thanks for your help! Your attached script runs perfectly and is laid out in a way that I can easily adapt. I’ve sent you a message with regards to my second question, I think what you’ve described is bang on :slight_smile:

1 Like

Good to hear ^^
I’ve just replied to your message :slight_smile:

Hello. Love your asset, super versatile and neat looking.

I’m having a problem with sprite layering.
I noticed the options for sorting layers and order in layer is in the rendering options, but they don’t seem to do anything when I use them, do I need to enable something for it to work? So far I have to move gameobjects in front or behind the water with their transforms, and while it works fine, it would be super neat if I could manage it with sprite layers instead.

Thanks!

1 Like

Hello, so happy you love the asset ^^

[UPDATED REPLY]
As of version 1.4, you can easily sort the water/waterfall object relative to sprites using sorting layers without any problem!
For more information, please check https://game2dwaterkit.haydeludos.com/water-system/#sorting-the-water-object-relative-to-sprites

[OLD REPLY]
Opaque objects (Geometry render queue) are rendered before transparent objects (Transparent render queue). And when rendering each queue, objects belonging to that queue are first sorted by various criteria (the sorting layer is just one of these criteria), then get rendered.
Hence, if the water’s rendering mode (in the water material editor) is set to Opaque, the water’s sorting order will be relative to other opaque objects and if it is set to Transparent, the water’s sorting order will be relative to other transparent objects (eg: Sprites).
So to control the rendering order of the water object relative to the sprites using sorting layers, the water rendering mode should be set to Transparent. Unfortunately, the water refraction and reflection effects are not available in that mode.
Therefore, the best way to order the water object relative to the sprites is to keep the water rendering mode to opaque and move the sprites slightly behind and in front of the water, just like you did :smile:

If anything is still unclear, please let me know!

1 Like

Gotcha! Thank you for your answer :slight_smile:

1 Like

You’re welcome! :slight_smile:

v1.3 Update should be available next week, and it will bring many improvements and exciting new features.
Any suggestions are greatly appreciated!
[Edit] Version 1.3 is now live!

Stay tuned! :slight_smile:

1 Like

Good to know! :slight_smile:

For what it’s worth, I always thought the water in Rainworld looked phenomenal:

I wonder if you could achieve a similar effect by offsetting the upper vertices on the surface strip? I don’t know enough about how it all works to provide much help here unfortunately, but just an idea.

2 Likes

Great idea! :slight_smile:
I’m definitely going to work on a similar effect. This would take some time to implement and test, so probably will be part of v1.4 update.
For now, though, I’m focusing on getting the update ready for release: improving the inspector, cleaning up and profiling the code.

Thank you :wink:

1 Like

Can we change the type of water material being used and if so how difficult is that?

Hello!
Could you please clarify what do you mean with the type of water material?

This asset is great! Used it for my own project. Screen capture - b8d269732029fe0e92e761f8af81caeb - Gyazo

2 Likes

Version 1.4 is released! :):slight_smile:

What’s new?

-New waterfall system
-Added support for the Lightweight Render Pipeline (LWRP) / Universal Render Pipeline (URP) [Upgrade Guide: https://game2dwaterkit.haydeludos.com/upgrade-render-pipeline/]
-Simulation Mode: Quickly tweak and test water/waterfall simulation properties in edit-mode
-Added support for perspective and isometric camera projections
-Gradient Color for the water surface -Texture Stretch tiling mode
-Texture Scrolling
-Reflection Fade
-Change Tint-Colors/Textures apply order
-Scale the reflection viewing frustum height
-Full support for sorting layers: You can now easily sort the water/waterfall object relative to sprites using sorting layers
-Sprite Mask Interaction: You can now hide/reveal parts of the water/waterfall object using Sprite Masks
-You can now define a fixed size for the refraction/reflection render-textures.
-Greatly improved the inspectors.

Note:
This version adopts a new folder structure, mainly a Runtime folder (scripts and shaders) and an Editor folder (custom editor scripts). So in case you already have prior versions of the asset in your project and want to adopt this new folder structure, please follow these upgrade instructions:
1- Open a new empty scene
2- Delete Game2DWaterKit folder
3- Import the new package

For more information:
Water System Guide: https://game2dwaterkit.haydeludos.com/water-system/
Waterfall System Guide: https://game2dwaterkit.haydeludos.com/waterfall-system/

1 Like

Hello HaydeLudos,
I have an issue with generating shaders when building a project on Windows10. I am using unity 2019.2.6f1 and it takes ages = 8 hours and I am still in the middle of shaders generation. I have around 4 millions small files created in Library/ShaderCache before I cancel this build process and it was still in the middle of shaders generation. Do you have any advice, how to optimize that? Before adding game-2d-water-kit it was a matter of a few seconds to create a build.

Hello,

I’ve recently came across this issue, and it turned out that adding any of the “Game2D Water Kit” shaders to the “Always Included Shaders”, in the Graphics settings, causes very very long build process.
I’m still investigating to see what’s exactly causing it. But for the time being, you can get rid of this issue by removing any “Game2D Water kit” shaders entries in the “Always Included Shaders” list. Then, please move the shaders to the “Resources” folder.

Shaders path: Game2DWaterKit/Runtime/Shaders
Resources folder path: Game2DWaterKit/Runtime/Shaders/Resources

Thank you! :slight_smile: