
Half-Life Alyx Update – The Booze Shader [video] - reddotX
https://www.youtube.com/watch?v=8kQW2jFPYZo
======
CyberDildonics
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.

------
flumpcakes
This seems like magic to me.

Granted I'm not a graphics developer, but given my current understanding of
shaders (programmable functions that are run on the gpu working on
textures/buffers?) I don't know how they interoperate with the physics engine
which I would assume is running on the CPU.

I would love to see a paper on how they did this!

~~~
dividuum
Here's some explanation on a similar effect and the surprisingly short shader
code:
[https://www.patreon.com/posts/18245226](https://www.patreon.com/posts/18245226)

It was referenced by Matthew here:
[https://twitter.com/skilful/status/1266494606847340544](https://twitter.com/skilful/status/1266494606847340544)

