URP 2D Liquid Shader Documentation

Shader properties and how to use them

Thanks for your purchase!

Below you may find detailed information on how to use the shader to get your desired effect along with important additional info!

1.          What is this shader?

Basically, this shader gives you the ability to create dynamic Liquid looking materials for your Sprite Renderers and UI Image components. It�s designed it Shader Graph and targets the Universal Render Pipeline.

 

2.          Requirements?

Minimum working Unity version: Unity 2020.3 LTS+

Minimum working Shader Graph version: Shader Graph 10.5+

If you have something lower than these, I cannot guarantee if the shader will work as intended.

 

3.          Important Notes Before you start

-       This shader is designed mainly for creating small liquids in containers. Using it for large applications like seas or oceans would not probably be ideal. You may see unexpected results if you do so.

-       Although it works on UI Image and Sprite Renderer components, it does not support masking through components. You must provide the alpha mask to the shader separately. It�s very easy to do so.

-       The shader is not intended for 3D use. But there is an Experimental version of it that supports 3D objects. It can work for certain situations, especially on 3D spheres. Try if you like.

-       The fields marked with () at the end can be dragged left right to alter the number.

 

 

4.          How to create from scratch

1)    Create a Canvas and a UI Image in it or a Sprite Renderer.

2)    Attach one of the Water sprites under URP Sprite Liquid Shader > Textures folder to the component�s sprite field.

3)    Create a new Material.

4)    Select URP Liquid > 2DLiquid shader for the material.

5)    Attach the material to the Material field of your image.

6)    Adjust the image color.

7)    If you want an easier access to the fill amount for scripting purposes, add a Fill Amount Setter component to the image.

8)    Experiment with the shader properties

And you're done! :)

5.          Shader Properties

Please note that most if not all of this information is also visible on the shader windows as tooltips as well.

Main Settings window:

-       Graphical user interface, application

Description automatically generatedDefault Color: The main tint of the image you get from the Sprite Renderer or UI Image component. Changing this is discouraged but you can experiment.

-       Contrast: Overall contrast. Can go negative or very high but will produce unexpected results at those numbers. Ideal range is around 0.5 to 2.

-       Random Seed: Random seed for various calculations. Advised to change if you're copying a material to create another liquid.

-       Fill Amount: Fill amount from bottom to top. 0 is Empty, 1 is Full.

-       Alpha Mask: Mask to use. Use this to fit the liquid inside an image like a potion or sphere. Check the examples for this. (See important notes before you start)

-       Transparency: Overall transparency. While the main color of the Sprite Renderer or UI Image component also applies transparency, this setting can go higher than 1 to produce overflowing results. Ideal range is 0-2.

 

 

 

 

 

 

 

 

 

 

 

Wave & Flow Settings window:

-       Wave Frequency: The frequency of the waves. Increased values mean you get more waves mixing in together. On high numbers, some repetitions may be noticed.

-       Wave Speed: Speed of the wave. Can go very high or negative but ideal range is 0-1.

-       Flow Speed: Speed of the inner texture mixing. Adjusts the flow of the main texture.

-       Distortion Speed: Speed of the inside distortion applied to the main texture. Higher values may produce unrealistic results.

-       Distortion Scale: Scale of the inside distortion applied to the main texture. As this goes higher, you see more and more distorted tiles.

 

 

 

 

 

 

 

Edge Settings window:

-      

Edge Alpha Shape: This is the main shape that creates the waves. Well-known trigonometrical shapes like sine, saw or triangle are recommended here but practically any texture with an alpha channel can be used.

-       Edge Scale: Scale (on Y axis) of the wave. Basically, makes the waves bigger or smaller vertically.

-       Edge Foam Offset: This determines the scale of the edge foam/glow. Min 0.

-       Edge Foam Color: Color of the foam. Can go HDR so it can glow under bloom.

 

 

Light & Glow Settings window:

-      

Light Texture: Texture to apply as a light source for a more 3D effect. Usually just a centered white radial gradient is enough.

-       Light Position: Position of the light texture. Wraps around.

-       Light Tiling: Tiling to adjust the scale of the light texture.

-       Light Opacity: Opacity of the light texture. Can go above 1.

 

 

Caustics Settings window:

-      

Caustics Density: Creates caustics from the provided main texture and adjusts its density.

-       Caustics Color: Color of the caustics. Usually just white is fine but can go different. Go HDR to make it glow under bloom.

-       Lens Distortion Texture: Texture for applying a lens distortion. Whites are distorted, alphas are not.

-       Lens Distortion Amount: Amount of the lens distortion.