Blog

Tips, news, and next Events about the KeyShot Community

How to Render Liquid In Glass with KeyShot

by KeyShot | Jul 1, 2016 | Tips | 2 Comments

Rendering liquids in glass can be challenging, but is very simple when knowing the most effective way to set up your model.

A common mistake is to use solid geometry, with many models including one solid to represent the liquid and one solid to represent the glass. This will usually create issues where the liquid and glass surface is coplanar leading to dark spots or triangles and incorrectly calculated liquid-glass interaction. Another common mistake is to offset the liquid slightly off the glass. This also gives an unrealistic result since, in reality, that air gap is non-existent.

keyshot-tips-liquid-in-glass-01

The Solution: Use Multiple Surface

To get the best results, break your model into three main surfaces:

Glass surface: Outer shell, or where only glass is visible
Liquid / Glass surface: Single surface where glass and liquid would touch
Liquid / Air surface: Single surface where glass meets air, adding a meniscus is nice bonus

We take these extra steps because we can then assign more advanced materials to each surface. All clear materials have a physically measurable Index of Refraction (IoR) value, which can then be replicated in KeyShot. For this exercise, it’s important to know the following IoR Values:

Air: 1.0
Glass: 1.5
Liquid: 1.334

keyshot-tips-liquid-in-glass-02

Apply the Materials

We can then assign more advanced materials such as Glass (Solid) and Liquid to our surfaces, then define the correct IoR value for both the inside and outside as needed. The liquid material includes the ability to define not only the IoR for the inside, but for the outside as well. This is key, since it allows light to behave as it does in reality: travel through glass, then liquid, then back through glass with no gaps or interference.

In this example we can assign Glass (solid) to our Glass surface, make sure the Refraction Index is at 1.5, then move on to our next part.

For the Glass / Liquid surface, we can increase the transparency to get a lighter effect, then adjust our Refraction Index. For the inside we can keep it at 1.334 (liquid), but set the outside to match our glass (1.5).

For the Liquid / Air surface, we can match the transparency, color, and Refraction Index of our other liquid surface, and keep the Refraction Index Outside to 1 (which is air). This will give us the correct setup, where light travels through the glass, liquid, and air correctly and without having any gaps between surfaces, overlapping surfaces.

keyshot-tips-liquid-in-glass-03

Adjust Your Settings

As usual, whenever working with transparent layers and glass make sure your ray bounce value is 10-20 (depending on your scene) and global/ground illumination is on as needed. Our Lighting settings for this scene is:

Ray Bounces: 16
Indirect: 1
Shadow Quality: 3
Self Shadows: On
Global Illumination: Off
Ground Illumination:On
Caustics: Off
Interior Mode: Off

We also adjusted an existing environment by adding a pin to the ceiling and making it very large but soft to remove dark black reflections in the glass.

Download KeyShot .ksp

arrow_down-green

Previous Article
Quick Tip 53: Roughness Textures
Next Article
How to Use KeyShot Real-time Region Rendering