I am searching now a little while for a solution to create a liquid in a bottle that behaves like real liquid but dont uses realtime fluid simulation.
Because that would not work good and is really cpu and gpu heavy!
Today I had a really great idea.
I found once on the internet a project from someone that showed a box that is moving left to right and everything that is inside this box is displayed and everything that is outside this box is clipped.
I found the project on my pc again but there are 2 big problems.
- the shader is outdated and unity has excluded it from OpenGL Es 2.0 and DX11 and my Project uses DX11.
- this method uses a texture to clip stuff and that texture is projected via script over the world from the clipping objects local position and rotation.
(I tryed it and it works for the liquid part but because it is projected over the world I will never be able to create a top face for the liquid.)
I found also another try from someone who made a shader that does nothing and this shader works like a mask. but it clips the whole object if it is between the camera and the bottle.
sooo. what I need is a way to clip everything from a specific object that is outside of a clippingobject. with that I could work.
Is there a way to do this?
EDIT:
I draw a little picture to better describe how I will setup this Idea.
btw to clip the liquid Surface I would use a copy of the liquid model.
link text
I made this really quick in blender to show how it would look if the bottle would be rotated.
the blue face is the liquid surface. the transparent blue plane is that whats been clipped away by the liquid model.
the gray liquid is inside of this box so it is visible. the upper half of the liquid is outside of the box so it is clipped.
I would write a script to the clipping box and the liquid surface so that it will not rotate with the bottle but will move with the bottle.