Author Topic: Smooth transition between different liquid types  (Read 122 times)

AndzQ

  • Newbie
  • *
  • Posts: 4
    • View Profile
Smooth transition between different liquid types
« on: December 02, 2018, 07:15:20 PM »
Good day Kronnect and other Liquid Volume users,

as a happy owner of the Liquid Volume Pro asset and long time user I eventually got stuck. For a project I need to implement a simple (yet so far frustrating) feature in which an Android user can change the property of a liquid by shaking the phone (the scripting part of this is not part of the question).

In theory a liquid would cover up the entire screen of the phone with a liquid of low viscosity (like water) that transitions into a thick liquid of high viscosity (like honey). Since the liquid fills the entire screen it would only need to be 2D. The image below illustrates the outcome we are aiming for.



Is there by chance a smart and easy way I can achieve such an effect with Liquid Volume Pro? It would already be immensely helpful if Id manage to create two settings that resemble the two illustrated states of the liquid with suitable bubbles and such. Im happy for any shared wisdom (:

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4083
    • View Profile
Re: Smooth transition between different liquid types
« Reply #1 on: December 03, 2018, 03:39:12 AM »
All properties shown in the inspector are animatable using LiquidVolume script. Changing any public property will automatically trigger a refresh during the frame. If you ever need to force a refresh you can call UpdateMaterialProperties() method or UpdateLayers() to update layers properties in case you modify the individual layer array fields.

Example using scripting:

Code
LiquidVolume liq = myObject.GetComponent<LiquidVolume>();
liq.bubblesVerticalSpeed *= 0.5f; // reduces bubble speed
liq.liquidLayers[0].color = Color.yellow;
liq.liquidLayers[0].murkiness = 0.5f;
liq.liquidLayers[0].murkColor = Color.green;
...
liq.UpdateLayers();

This will automatically lerp current values to the new values based on the Adjustment Speed parameter.

AndzQ

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Smooth transition between different liquid types
« Reply #2 on: December 03, 2018, 09:46:43 AM »
Thank you for the quick response which already helped me setting up a smooth lerp between the two liquids.
As a final question - can I somehow manipulate the appearance of the bubbles. The bubbles look totally allright at small sizes, but when I increase the size of the bubbles to match the ones in the previously posted reference image, the bubbles appear grainy and pixelated.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4083
    • View Profile
Re: Smooth transition between different liquid types
« Reply #3 on: December 03, 2018, 10:59:30 AM »
Have you tried the bubblesScale and bubblesMaxSize properties?

AndzQ

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Smooth transition between different liquid types
« Reply #4 on: December 03, 2018, 12:25:18 PM »
Yep, tried them. I pretty much played around with any property that had "bubbles" in it but I couldnt get some clean bubbles like in the reference image above. Not sure if this sounds like a dumb question, but can I somehow replace the shape/appearance of the bubbles with a custom one in the same way I as changing the material of a particle in a particle system?

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4083
    • View Profile
Re: Smooth transition between different liquid types
« Reply #5 on: December 03, 2018, 12:31:19 PM »
Not as immediate as they are not sprites. Bubbles are precomputed in a 3D texture, then ray marched, therefore the resolution of the 3D texture determines the sharpness of the bubbles. Ill check if that texture can be enlarged using some option.

AndzQ

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Smooth transition between different liquid types
« Reply #6 on: December 03, 2018, 12:56:22 PM »
I see. An increased sharpness would already help me a lot as the bubbles themselves behave really good. Theyd also look fantastic if my particular scenario would not include such a close up display of the liquid. Thanks for the help. Hope its not too much trouble.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4083
    • View Profile
Re: Smooth transition between different liquid types
« Reply #7 on: December 05, 2018, 03:11:34 AM »
Tested higher resolution 3D texture (from 64^3 to 128^3), unfortunately that option won't be a good choice since it skyrockets memory demand to 2MB which would produce memory pressure issues on mobile/WebGL.
In this case, to get a super-sharp bubble effect since the liquid fills the full-screen a better option would be to combine it with a particle system using bubble sprites on top of the liquid.