©BBB3viz

Table of Contents


Overview


This article discusses how to use V-Ray for rendering refractive surfaces that are in contact. This is a typical scenario for scenes with liquids contained in glass or other transparent, or semi-transparent containers.

Here we examine some potential modelling mistakes and the correct workflow with V-Ray. For shading guides on how to create water material, or glass material, follow the links. We won't go into great detail about the shading process here, but offer some tips.

Additionally, we show a basic caustics effect workflow to complete the final image.

Scene Setup



Here is how the scene is build - it contains a teapot, a glass cup and some additional models for aesthetic purposes.

There are two types of glass applied - clear glass on the main parts of the teapot and the cup, and tinted glass - on the teapot's spout and handle, and on the cup's handle and dish.




Geometry


For the geometry creation, we focus on the cup model since it's simpler, but the teapot is created the exact same way.

The fastest and the most accurate approach is to reuse the already built geometry of the cup, instead of creating the liquid model from scratch. Thus, the liquid geometry has the exact same contour, overall shape and volume as the cup.

By selecting and cloning the necessary inner-side polygons, we're creating the main body of the fluid.

Don't forget to flip the polygons' normals, as they should point toward the cup’s surface.





After the capping, special attention to the top surface topology is needed, as we want to avoid a messy topology and distort the refractions.






Also, adding 1 to 2 mm chamfer to the surface edge of the liquid introduces additional realism in reflections and refractions when rendered. This is how all water-based mediums interact with glass objects.





Unwrap the geometry and add proper UVs for the liquid mesh. Add a smoothing subdivision.

You can skip the unwrapping process, if you use a Triplanar map.


Modelling Workflows


The issue with rendering two refractive surfaces in contact, 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 options:

  • Aligned: The liquid and the container are with aligned geometry with no gap between them.
  • Without intersection: 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 detached from the container.

  • With intersection: 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.

See the following images for the three main situations regarding the geometries positions - aligned geometries, geometries without intersection and geometries with intersection:



Aligned

Without intersection

With intersection





As shown in the renders, the two approaches with aligned boundaries and the gap between the surfaces, render artifacts. For proper appearance in terms of reflections and refractions, position the geometries so that they intersect each other and avoid coplanar faces. This prevents from artifacts in the rendered image.


Shading



The Tea material, as a water-based material, has mostly the same parameters as a Water material. The only difference is that we use Fog color (RGB: 259, 225, 165) to simulate the typical yellowish color of tea.

Notice how the two liquid volumes have different color, even though they use the same material. This is caused by the non-white Fog color applied to the two liquid volumes, whose geometry thickness varies. V-Ray Fog makes the thick objects look less transparent than thin objects.





The overall look of the Tea material can be improved by adding detail to the Fog by using texture maps. In the example, a general 3d Noise map with Fractal Noise Type is used as a Fog color map.

The variation in the volume color makes it look realistic.


Bonus: Caustics



When rendering scenes with refractive surfaces such as glass and water, caustics add this little detail that makes the render closer to photo-realism. Let's explore how to set caustics for rendering with V-Ray.

The caustics effect requires a lot of computing power and may slow down the rendering times.

By default, VRayMtl uses the Affect shadows option to cast transparent shadows and to create a simple caustics effect, which is dependent on the Refraction value and the Fog colors. To achieve more accurate caustics, disable this option and instead enable the Caustics parameter in the GI tab.

Set Progressive as the Calculation method. The Progressive method in combination with a VRayDenoiser render element allow you to stop the render whenever you are satisfied with the result.

Turn off the Generate caustics option in the V-Ray light properties of every light in the scene, that you don't want to generate caustics for. For example, dim secondary lights, fill lights, etc.

Additionally, if you have large surfaces such as background walls, ceilings, floors or objects, which don't need to receive caustics or have little contribution in the overall look of the caustics, you can turn off the Receive caustics option for those objects in their V-Ray object properties.

This example shows both the denoised Beauty render and the VRayCaustics render element.


Caustics RE
Beauty RE



Lastly, brighter, more playful and better-defined caustics can be achieved with a stronger directional light. VRaySun is used in this last example.


Caustics RE
Beauty RE

Note that the Progressive caustics are still WIP and might not be suitable for all scenes. For more information, see the Caustics page for their known advantages and limitations.