Liquid Shader
A shader that looks like liquid in a container.
Shader code
GitHub
Sloshing code GitHub
How it works.
Fill amount:
The fill amount is determined by a predefined value, if the pixel is above this value it gets discarded.
Then it colors the top of the sides a predefined color, the inside of the object also gets colored the same color making it look like
it has a top.
Sloshing:
The sloshing is determined by putting the velocity and position values in a sin formula and adding this to the fill amount to make it slosh
when it moves.
Back