Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


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

...


Section
Column
width50%

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.

Column
width5%


Column
width45%

Image Added



Geometry

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

...

...

Section

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
Column
width50%

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.

UI Text Box
typenote

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

Column
width5%


Column
width45%

Image Added


...


Section
Column
width50%

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

Column
width5%


Column
width45%

Image Added



...


Section
Column
width50%

Also, adding 1 to 2 mm bevel 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.

Column
width5%


Column
width45%

Image Added


...


Section
Column
width50%

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

UI Text Box
typetip

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

Column
width5%


Column
width45%

Image Added

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:

Fancy Bullets
typecircle
  • 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

like a solid block
  • 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:


Section
Column
width5%


Column
width30%

Aligned

Image Added

Column
width30%

Without intersection

Image Added

Column
width30%

With intersection

Image Added

  • 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.

     
    Column
    width5%


    Section
    Column
    45%
    width5%


    Image Removed
    Column
    width

    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.

     

    Image Removed

     

    Part I: Initial Rendering

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

     

    Image Removed

     

     

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

    Image Removed

    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.

    Image Removed 

     

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

    Image Removed

    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.

    Section
    Column
    width10%

     

    Column
    width40%

    Image Removed
    viewport with liquid and glass

    Column
    width40%

    Image Removed
    render with the liquid not touching the inside of the glass

    Column
    width10%

     

    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:

    Image Removed
     

    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:

    Image Removed

    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

    Image Removed

    Now render the frame:

     Image Removed

    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.

    Image Removed

    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:

    Image Removed

     

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

     

    Image Removed

     

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

     

    Image Removed

     

     

    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.

    Image Removed

    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.

    Image Removed

     

    The final render should look like this: 

    Image Removed

    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;

    30%

    Image Added

    Column
    width30%

    Image Added

    Column
    width30%

    Image Added

    Column
    width5%



    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

    ...


    Section
    Column
    width50%

    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.

    Column
    width5%


    Column
    width45%

    Image Added


    ...


    Section
    Column
    width50%

    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 Noise map with Fractal Noise Type is used as a Fog color map.

    The variation in the volume color makes it look realistic.

    Column
    width5%


    Column
    width45%

    Image Added

    Bonus: Caustics

    ...


    Section
    Column
    width50%

    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.

    UI Text Box
    typenote

    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 Denoiser render element allow you to stop the render whenever you are satisfied with the result. This approach is more suitable for still images, rather than animations. Alternatively, set Max render time (from the Progressive Image Sampler settings)for your render.

    You can 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.

    Column
    width5%


    Column
    width45%
    Before after
    afterLabelBeauty RE
    beforeLabelCaustics RE
    Panel
    borderStylenone

    Image Added

    Panel
    borderStylenone

    Image Added


    ...

    Section
    Column
    width50%

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

    Column
    width5%


    Column
    width45%
    Before after
    afterLabelBeauty RE
    beforeLabelCaustics RE
    Panel
    borderStylenone

    Image Added

    Panel
    borderStylenone

    Image Added

    UI Text Box
    typeinfo

    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

    ...

    .