How displacement maps work and how to optimize them in V-Ray Part 1

How displacement maps work and how to optimize them in V-Ray Part 1

Introduction

This guide shows how to optimize the settings of the V-Ray displacement feature for 3ds Max. Although, what can be learned about V-Ray here works on any compatible 3D application.

Displacement mapping is a powerful tool to add complex geometries on a surface without having to model them manually. It allows you to add realistic details to your models beyond what “classic” poly modeling can do.

For example, with just a few clicks, you can transform a simple square into a wall with visible sculpted elements such as bricks, plaster, or moldings.

Contents

  1. Displacement, Bump, and Normal Mapping
  2. Where to set up Displacement in 3ds Max and V-Ray
  3. Typical symptoms of poorly optimized displacement settings (AKA scene uses too much RAM)
  4. VrayDisplacementMod modifier -> 3D mapping -> View-dependent turned on
  5. VrayDisplacementMod Modifier -> 3D mapping -> View-dependent turned off
  6. Summary
  7. Sources
  8. Useful links
  9. Credits
It’s not only color or reflection; the 3D surface of the material also needs to be reproduced for a realistic look.

First, let’s have a look at how displacement works as opposed to bump and normal mapping.

Displacement, Bump, and Normal Mapping

It’s not only color and reflection. Each surface contains a 3D structure through which, slick or rough, we perceive texture by how light bounces off its bumps and scratches. It’s this essential trait in materials that make them look interesting and real.

Given this all-important feature in real surfaces, 3D applications quickly incorporated tools in their material editors necessary to generate such an effect.

One is the bump map. By taking the placement of light on the model into consideration, it imitates a sculptural relief on the surface, portraying shadows and highlights to simulate texture and depth.

However, bump mapping doesn’t create a real 3D structure. Instead, it creates an illusion of 3D, “faking” it during the render process by having light bounce off simulated features that are not actually there. It does the job for small, finer details, and only in some angles. You wouldn’t, for example, see changes to the contour of the object. There are cases where it doesn’t look all that convincing.

Another method is the normal map (normal bump). It does the same job as bump mapping, except the details are created based on an RGB color map that encodes the angles of the surface. Like bump mapping though, the effect is purely based on rendering; it doesn’t add real detail to the geometry. It’s thus mostly used in computer games to add detail to models while keeping a low polycount.

Contrary to those methods, displacement mapping creates real 3D geometry; it casts real shadows and looks realistic from every angle. It does so by dividing the model’s polygons into a much denser mesh during the rendering process, which is either elevated or depressed on an up/down axis based on your chosen texture. The downside of this method is that it can create very heavy meshes that require a lot of RAM to process.

Bump, normal bump, and displacement can be used in various scenarios depending on the required level of quality and computer performance constraints.

You can create a displacement map in Photoshop using photos of reference materials, sculpt it and bake in programs like Zbrush or Mudbox, or by using quick displacement map creators like CrazyBump or NormalMapOnline (Check out the software list at the end of the guide for creating such maps.)

You can also use Integer or Float maps. Artists working on character creation and other complicated sculptures usually export Float maps from software like Zbrush. In simpler modeling tasks like ArchViz, you can get away with Integer maps created from pictures of various surfaces.

Where to set up Displacement in 3ds Max and V-Ray

There are two methods of setting up displacement in 3ds Max and V-Ray.

  • The first is to set it in Render Setup (V-Ray) -> Settings -> Default displacement in conjunction with Material Editor -> Maps -> Displace
  • The second way is adding the VrayDisplacementMod modifier and linking a map from Material Editor to the “Texmap” slot (as Instance)

Using the VRayDisplacementMod modifier provides more flexibility in setting up displacement features and managing resources necessary for rendering.

Displacement features settings – These influence render times and RAM used by the scene. They need to be set to specific values to get the exact look of the displaced model you want. Therefore, these values should not be compromised for the sake of optimization. Please turn to the other settings listed below instead.

Quality settings – These set the displacement’s level of detail, number of subdivisions, and mesh density. They are decisive in the number of resources your scene needs for rendering, and we will optimize them in the next chapters of the guide.

Performance and other settings – These are special settings that affect rendering performance; they can be used in rare scenarios for debugging displacement-related issues, like artifacts or unusually high resources usage. We will talk about them at the end of the guide.

According to the V-Ray manual, there are three types of mapping in VRayDisplacement Mod:

  • 3D mapping – A general method that takes the original surface geometry and subdivides its triangles into smaller sub triangles which are then displaced.
  • 2D mapping – Bases the displacement on a texture map that is known in advance. The displaced surface is rendered as a warped height-field based on that texture map. The actual raytracing of the displaced surface is done in texture space, and the result is mapped back into 3D space.
  • Subdivision – Similar to the 3D mapping method, with the difference that it applies a subdivision scheme to edges (similar to a MeshSmooth modifier). We will skip that method in this guide.

We will use VrayDisplacementMod modifier setup for tests because it has all the options which displacement from render settings provide and more, and it allows you to set displacement options separately for each model in a scene.

We will use various variants of the scene below for tests.

The test scene contains three boxes with VRayDisplacementMod added. GI is set to Brute Force + Light Cache

Tests setup:

Hardware: Intel V2 processor, 2.80 GHz, 128 GB RAM
Software: 3dsMax 2017 + V-ray 4.10.02
GI was set to Light Cache + Brute Force, default settings
All other settings were left as default.

Typical symptoms of poorly optimized displacement settings (AKA scene uses too much RAM)

  • 3ds Max crashes or freezes
  • Rendering falls into an endless loop of calculating Light Cache / presampling displacement / Unloading geometry
  • Rendering gets stuck at the “compiling scene geometry” stage or at “building Embree static accelerator”
  • The CPU usage is low or irregular
  • In the event of RAM shortage, 3ds Max uses the hard drive as additional storage for displacement data and swaps it between HDD and the processor. This substantially lengthens a scene’s render time.

In the following tests and examples, we will have a look at V-Ray displacement options and find a way to create a render as detailed as we need it to be while using the least amount of computer resources possible.

VrayDisplacementMod modifier -> 3D mapping -> View-dependent turned on

The main quality setting in VrayDisplacementMod set to 3D mapping is Edge Length, which, by default, has View-dependent option enabled.

Before displacing the geometry, VRayDisplacementMod subdivides the triangles of the object into smaller ones. When the View-dependent option is on, the Edge Length value determines the maximum length of a sub-triangle edge in pixels.

For example, a value of 1.0 means that the longest edge of each sub-triangle will be about one pixel long when projected onscreen (i.e., the rendered image).

More, smaller sub-triangles are created at smaller values. That directly means more detail in displacement, slower render times, and, most importantly, more memory usage.

Let’s check the quality of displaced geometry and the number of used resources when this setting is set at various values.


Chat