3 ms·
There have actually been simple shaders for liquid inside spheres floating around for a while. If know you won't ever have the water surface actually break up
by CyberDildonics 6y ago
There have actually been simple shaders for liquid inside spheres floating around for a while.
If know you won't ever have the water surface actually break up you can start with knowing the surface will always eventually be a flat plane in x and z. From there you will need to make sure the plane is at the right place in y with the orientation and volume of the bottle. This could just be a 1D lookup table on cylindrical bottles since spinning the cylinder around the axis it was swept/lathed won't change anything. There was a square bottle but I'm not sure how tightly the volume is preserved there.
The surface deformation might be noise and ramps that oscillate and settle, while the bubbles look like spheres deformed with a simple field like sin waves so they jiggle as they move up.
All of this is implicit geometry that can be rendered by raymarching in the shader for the bottle surface. This gives you the refraction, the liquid density falloff and the bubbles. The foam is a cool detail too although I don't think it complicates things too severely. The person in the video mentions that he couldn't get the liquid to penetrate the edges of the bottle, but it is unlikely there is any geometry used except for the bottle.
That's my guess in how it is done.