I’ve been researching using a material to fake a liquid in a container and there’s been some great work done by various people that have all come close to the solution but never quite got there.
The general approach is using the Z plane to drive a mask as shown here:
This method is fine for block colour since it hides the fact there’s no surface plane on the liquid due to the nature of the opacity masking, but I’m after a solution which ends up with a surface.
There was also an approach which takes it a step further shown here:
that tried to use world position offset, essentially looking down and finding the silhouette of the object at that point from above then pushing the top verts down but it falls apart when rotating and the approaches I’ve tried to fix it haven’t yielded any results.
I was wondering if anyone has any ideas on how to fix the method shown above or maybe any other approaches to fixing this problem?
Use local position instead of world position for your calculations.
When I use local position instead of world position, it does move up and down within the container correctly but since it’s local space it doesn’t have the same motion of water in a container that you get with the world space method, see the two below:
Also when you rotate it and move it about with local position it’s affecting the material negatively in the ways shown below(ran out of upload limit on here so have to use external links):
It’s quite possible I have just implemented this wrong but this is the effect I would expect to see. Ideally a way to somehow combine these methods would be great but I’m at a loss if it’s actually possible. I’m also not sure on what other material approaches I can take with this since world offset seems to be the only possibility.