Unity fills a Sprite Shape with as few triangles as it can get away with. That is perfectly reasonable for a static shape, but it leaves the Liquid Shader with almost no vertices to displace, and the waves and ripples with almost nothing to act on.
LiquidSpriteShapeGeometryCreator.cs solves this. It is a SpriteShapeGeometryCreator – a ScriptableObject that the Sprite Shape Controller uses in place of Unity's built-in geometry generator. It fills the spline with an evenly tessellated grid of triangles and generates matching UVs, while keeping the collider working as usual. It also writes an edge mask into the red channel of the vertex colors, which the shader uses to fade out the emission towards the outline of the shape.
The Geometry Creators folder contains three ready-made assets. To use one, drag it onto the Creator field of your Sprite Shape Controller.
- Liquid Sprite Shape Geometry Creator – a general-purpose creator with the maximum Mesh Detail and practically no edge mask.
- Liquid Sprite Shape Geometry Creator - Lake – a lighter mesh with a moderate edge mask, suited to calm lakes and pools.
- Liquid Sprite Shape Geometry Creator - Edge – the maximum Mesh Detail with a much wider edge mask, for a broad, cooled rim.
To create your own, use Assets > Create > Project GAMEDEV > Essential 2D Shaders > Liquid Sprite Shape Geometry Creator.
Mesh Detail
The density of the generated mesh (1 to 128), i.e., both the number of vertex columns per local unit and the number of quad rows. This is the most important setting of the asset: higher values produce smoother, more detailed vertex displacement, at the cost of a heavier mesh. Values around 12 to 32 are plenty for a calm liquid; violent lava benefits from far more.
Open Ended Width
The total width of the generated strip when the Sprite Shape spline is open-ended rather than closed. The spline stays centered within the strip. Closed shapes are simply filled and ignore this setting.
Stretch UVs To Bounds
Generates the UVs from the bounds of the generated mesh instead of tiling them from the local position. Enable this to stretch a single copy of the liquid texture across the whole shape; leave it disabled to tile the texture at a consistent scale, regardless of the size of the shape.
Edge Mask Width
The distance from the outline of the Sprite Shape over which the edge mask fades out. The mask is stored in the red channel of the vertex colors, and the shader uses it to darken the emission near the outline. A wide value produces a broad, cooled rim, while a very small value effectively disables the rim.