This tutorial will help show you some techniques for rendering a liquid inside a glass.


Page Contents



In this tutorial, we discuss using V-Ray for rendering refractive surfaces that are in contact. A typical example of this is rendering a liquid in a glass container.

One issue is that we have two separate objects, which share the exact same surface boundary. From a modeling point of view, it is very difficult to ensure that the two objects have the exact same boundary geometry. While this can be achieved for static scenes, things may become very problematic in animation.

From a rendering point of view, if the two surfaces match exactly, the renderer cannot distinguish between them accurately, which may lead to errors in the rendering.

Considering these two issues, it is obvious that we need to separate the surfaces or to model the surface interface separately. We have the following three options:

  • The liquid and the container do not touch and have a gap between them. This approach is simple to implement and does not require any special support from the renderer. However, it does not produce a realistic result. This is because the gap between the two surfaces changes the rendering drastically and makes the liquid look like a solid block.

  • The liquid overlaps the container. This approach potentially produces much more realistic results, but it requires special support from the renderer. This is because the renderer must keep track of which surfaces have been intersected along a ray path so that it can compute the correct index of refraction. Without this built-in support, this method cannot be used. Luckily, V-Ray supports the necessary framework for this, which makes this approach the preferred one.

  • The third approach is to model the interface separately. In general, this is difficult to implement; especially in animations. Furthermore, this approach introduces a third object into the scene with a separate material, which makes things more complicated. Additionally, it will not work very well with things like fog in the glass - since in this case, V-Ray cannot make the connection between the glass/liquid material, and the surface interface material, and cannot apply the correct fogging value.


Below, we discuss the first two methods only; the third method is more difficult and is not recommended.


Tutorial Assets

To download the file used in this tutorial, please click on the button below. This scene was created in Maya 2016 and can be opened in that version or newer.



Part I: Initial Rendering

Open the starting scene, available from the assets section above.




In the Render Settings window, make sure that the Render Using drop-down is set to V-Ray.

Next, let's get some GI in the scene. In the Render Setting's GI tab, then under the GI rollout, turn On GI. Also, disable the Refractive Caustics setting. We will add photon-mapped caustics later for the final image.



Render the scene (). The V-Ray render should look something like this:

This shows the container that we will fill with liquid in the next section.



Part II: Rendering the Liquid

Now let's add liquid inside the glass:

Using the Outliner, un-hide the liquidInsideGeo object (by pressing Shift+H). If you look at the scene through the Front or Side viewports (shown below), you'll notice that the liquid object is slightly set inside the glass container, without touching it. With the liquid object now visible, render a frame to see an image like the render below.


viewport with liquid and glass

render with the liquid not touching the inside of the glass


Although the distance between the container and the liquid is really small, the rendering does not look realistic, particularly at the bottom of the glass - it looks like a glass with a solid glass block inside it. To avoid this, let's make the liquid overlap the glass a little bit. Luckily, that is already done for you:

Hide the liquidInsideGeo object (Ctrl+H) and unhide the overlappedLiquidGeo object (Shift+H).

Using the Front or Side viewports, you should notice that this liquid object overlaps the inside of the glass object a little bit:


Render the scene again and the glass with the overlapped liquid object looks like this:

Now it looks better; the liquid really seems to be touching the glass.

Part III: Final Rendering

For the final rendering we would like to improve the antialiasing, get rid of any noise and to add some caustics for a better, final look.

Turn Caustics on from the Caustics rollout at the bottom of the GI tab of the Render Settings. Leave the attributes at their defaults and render a frame to see the result below:

Some caustics appear on the ground plane in front of the glass and are somewhat blotchy. Furthermore, no caustics seem to be going through the glass. In the Hypershade, select the glassMtl and in the Refraction rollout, turn off Affect Shadows. Affect Shadows is good for transparent objects casting proper shadows but doesn't allow for proper refractive caustics using photons. Select the waterMtl and turn off Affect Shadows as well (shown below) for the liquid inside the glass

Now render the frame:


Set the Max. density to 0.2. This provides a little bit of a smoothing effect. Define a region at the bottom of the glass as shown below, and render that region to see the caustics now.

The caustic effect looks smoother than before, but perhaps a bit strong going through the glass. Set the Multiplier to 0.8 and render to knock it back just a little bit:


The Caustics settings in the Render Settings window, GI tab currently look like this:



Turn off Region Render and render a full frame, and it should look like this:




Caustics look better now and these are the settings to use for the final rendering. If you want even smoother caustics, further increase the Max Photons parameter. For more on rendering caustics, click here.

Optional: Saving Caustics Calculations

In order to avoid recalculating the caustics every time for the further renderings, use the Save button under the Caustics Mode to create a .vrpmap file, then set the Mode type to From file, so the Browse button becomes available to choose the file you just created.

Increase Anti-Aliasing Quality

Now we need to improve the antialiasing and to reduce the noise from the area lights.

Go to the VRay tab and in the Image sampler rollout, set the Sampler type to Bucket. Then from the Buckets subsection, set the Threshold to 0.005.


The final render should look like this: 

Alternative Rendering Approach

Another way to render the image is to use the Progressive image sampler in V-Ray.

4.1. Turn off the photon-mapped caustics;

4.2. Set the primary and secondary GI engines to Brute force;

4.3. Turn on the Refractive caustics option that we disabled before;

4.4. Set the image sampler type to Progressive;

4.5. Render until you like the result.