Search Keywords: displacement, displacement mapping, 2D, 3D
In this tutorial we'll examine displacement mapping in V-Ray. We will concentrate on the 3d displacement mapping method.
Displacement mapping is a technique for adding geometric detail to surfaces at render time. In contrast with bump mapping, which works by just changing the surface normal to create the illusion of surface detail, displacement mapping modifies the surface itself. Here is an example of the same object rendered with bump mapping and with displacement mapping:
Original object Bump mapping Displacement mapping
In the case of displacement mapping, the surface is actually modified, which leads to correct outline, shadow and GI. In the case of bump mapping, although the surface appears modified, the outline and the shadow stay the same.
Note that displacement is different from other kinds of shading, since it needs to modify the actual object surface. Therefore an object must be displaced before it can be rendered. This is why in V-Ray displacement is represented with a modifier (although the modifier can take the displacement map from the object material).
Start with an empty scene. Create a GeoSphere with a radius about 40 units in the viewport and choose V-Ray as the renderer. Apply some Standard material to the sphere.
Go to the Modify panel and apply a VRayDisplacementMod to the sphere. If you render straight away, you will notice a slight displacement effect, like so:
This is because V-Ray applies a simple noise displacement map when no other texture is chosen.
To select another map, click the texture button in VRayDisplacementMod. This will bring up the Material/map browser dialog. Choose a Cellular texture. To edit the newly created map, open the Material Edtior and drag the map from the button in VRayDisplacementMod to a slot in the Material Editor. Choose the Instance method when you drop the map.
If you render again, you should get a similar result:
To make the displacement effect more pronounced, increase the Amount value of VRayDisplacementMod. If you set it to 5.0 and render you will get something like this:
The Amount value determines the maximum displacement amount (which occurs at places where the displacement map is white).
You can shift the whole displacement map up and down by adjusting the Shift parameter. The effect will be to expand (for positive Shift values) or shrink (for negative Shift values) the displaced surface. Here are some examples of different Shift values:
Shift = -5.0 Shift = 0.0 Shift = 5.0
Note that the Shift parameter is an absolute value in world units. If you change the Amount, you will probably need to adjust the Shift too.
The Use water level and Water level parameters allow you to clip parts of the object. Return the Shift value to 0.0, if you have changed it. Then turn on the Use water level option and set the Water level to 2.5:
The geometry is clipped away for those places in the displacement map where the displacement value is below the Water level. Here are a few examples of different Water levels (assuming the Amount parameter is still 5.0 and the Shift parameter is 0.0):
Water level = 0.0 (no clipping) Water level = 1.25 Water level = 2.5 Water level = 3.75 Water level = 5.0 (all geometry is clipped)
The Water level parameter is also absolute in world units. If you change the Amount and/or Shift, you will probably need to adjust the Water level to get the same effect.
For 3d displacement, the geometry is clipped on a sub-triangle basis - a subtriangle is either clipped away entirely, or completely visible (this is not the case for 2d displacement where clipping is more precise). Therefore, you may get a jagged effect at the clipped edges. You can reduce this effect by producing more subtriangles (see the next section).
V-Ray does 3d displacement by subdividing each triangle of the original object into a number of subtriangles. More subtriangles mean better displacement, but will also take more memory and will increase the render time. To get a better idea of how many subtriangles you have, apply a Standard material to the sphere (if you haven't done so already) and turn its Faceted option on. This is important, as otherwise V-Ray will not only smooth the surface normals, but will also automatically apply a normals map that represents the normal of the perfect displaced surface, which will make the surface look a lot more detailed that it actually is. Also, switch off the Use water level option of VRayDisplacementMod, if it is on. If you render, you should get a similar result (click the image for a larger view):
Here is a blow-up of this rendering to better show the individual subtriangles (click the image for a larger view):
In addition, here is a rendering that shows the boundaries of the original triangles of the sphere. To do that, put a VRayEdgesTex map in the Diffuse slot of the material and instance this map into the Self-illumination slot. Set the Color of the edges in the VRayEdgesTex to red and the Thickness to World units:
The quality of the displacement is determined by the size and number of the subtriangles. The main parameter to tweak is the Edge length. It determines the maximum length of a subtriangle's edge. This can be in world units or in pixels, depending on the View-dependent option. Lower values for Edge length mean smaller triangles and better quality. Here is the previous image rendered with various values for Edge length (with View-dependent turned on). Note that the View-dependent option refers to pixels in the original image, not the zoomed-in image you get with a blow-up rendering. This is why we were able to do a blow-up rendering to see the individual subtriangles better. Click the images for a larger view:
Edge length value Normal rendering Blowup rendering 0.5 1.0 2.0 5.0 10.0