Skip to content. Skip to navigation

Illuminate Labs

Sections

Displacement Mapping Tutorial

This tutorial is divided in to tree parts. First, we will look at one scenes to illustrate Turtle's displacement features. Then we describe the user interface and all parameters. In the last part will we be looking at a how to use displacement maps from Pixologic's ZBrush.

Project files: displacement.zip

Scene 1

Open the scene dispTutorial_Scene1.mb. It is a simple scene with the Turtle logo displaced on a plane, where we demonstrate the use of the displacement node.

  • Assign the shader s_color to p_displacePlain.
  • Assign a displacementShader to the displacement slot on sg_color. Set the Subdivisions to 25 and disable LOD, disable Micro Polygons, it is only needed on objects with high polycount.  

  • Map a texture to the displacement attribute of the displacementShader node. Set the texture node to load turtleLogo.jpg, the file can be found in the textures dir of the Maya project. Set the Filter Type to Mipmap (this will speed up the rendering) and set the Alpha Gain to 0.05  

With this scene Turtle will render this frame:

User Interface

Turtle adds some attributes on the displacement shader:

Max Subdivision

The maximum amount a side of a base face will be subdivided in order to capture details in the displacement map. For example: A value of 10 means that a triangle will be subdivided into 10*10 micro-triangles.

Enable LOD

This enables the LOD calculation, that automatically will adjust the number of micro-triangles to a good level. Max Subdivision still sets the upper limit a base mesh face can be divided into, but in most cases, this limit need is not reached, except for faces close to the camera.

LOD Quality

This parameter forces the LOD algorithm to tessellate harder (if larger than 1) or more sparse (of less than 1), thus creating an even finer, but still adaptive tessellation. The suggested tessellation from the LOD computation is multiplied with this value. This allows you to trim the LOD feature.

Micro Polygons

This attribute enables us to choose between render time displacement or pre-tessellation. Turtle will displace the geometry at render time when Micro Polygons are enabled. Render time displacement is more memory efficient but slower than pre-tessellating.

When pre-tessellating, Turtle will subdivide each triangle according to the Max Subdivision setting. The pre-tesselation displacement height differs from micro polygon displacement object/world space. We will have to readjust the displacement height when switch to pre-tesselation mode.

Smooth Base Mesh

This is a convenient feature when working with fine, small scale displacements on coarse polygon base meshes. This feature adds a smoothing value to each displacement value to improve the smoothness of the base mesh, and thus make sure that no base triangle borders are visible on the final rendered displaced image. This feature will increase the rendering time, but is a valuable tool to obtain nice-looking displacements, even on coarse base meshes. Note that this feature will only smooth per triangle, using the normal and position of the current triangle to obtain a smooth surface with G1 continuity at triangle corners. This means that you can not expect the algorithm to smooth complex mesh features spanning over a number of triangles. Use the feature Render as subdivision surface for larger scale smoothing.

Max Ray Offset

When combining displacement with Turtle FG and Occlusion, this parameter has to be adjusted to avoid self-shadowing artifacts. A good rule-of-thumb is to set this value to half the displacement scale value if you are using both positive and negative displacement. If the displacement is positive only, leave the ray offset at zero.

Scene 2

In this scene we are going to render a object from Pixologic's ZBrush. To get good results, we will begin with describing two of Turtle's features that we will need to use.

Render As Subdivision Surface

An attribute found under the shape node of all poly meshes. This command subdivides the mesh before rendering, so that the base mesh gets a smoother look and is prepared for the displacement map from ZBrush.

The File Texture node

For ZBrush maps, the default output is grayscaled TIF 16 bit images, with black representing negative displacement, grey zero displacement, and white positive displacement. ZBrush also flips the map in the vertical direction when exporting. With this in mind, we check the ZBrush Map on the texture slot. This will flip direction of the file and adjust the offset to 0.5, so that the zero displacement level is indeed grey.

We will set the height of the displacement using the Alpha Gain attribute.

The Displacement Shader

The default settings on the Displacement Shader will work in most cases. But we will enable enable Smooth Base Mesh for close-up shots. This will smooth the generated micro-triangles further, but will also somewhat increase the render times.

The Max Ray Offset is used to avoid incorrect self Occlusion and Final Gather effects when using negative displacements, and can also smooth the displacement detail. A good rule-of-thumb is to set Max Ray Offset to half of the displacement scale if you are using both positive and negative displacements, but leave it at zero if you are using a positive map.

The Pixologic Head

The workflow of importing a object from ZBrush is very simple. Assuming you have a base mesh and a ZBrush generated TIFF displacement texture. The steps are:

  • Import the base mesh.
  • Under the shape tab of the imported mesh, enable Render as Subdivision Surface.
  • Assign a material to the base mesh.
  • Connect an displacement shader to the Displacement Mat. slot of the shading group. Enable Smooth Base Mesh of the shader.
  • Connect a file texture node to the displacement attribute of the displacement shader. Enable the Zbrush attribute and load the displacement map.
  • Use the Alpha Gain of the file texture node to adjust the scale to the amount of displacement.  

 Render As Subdivision Depth:2
 Max Subdivisions:100
 Enabel LOD:ON
 LOD Quality:1.5
 Smooth Base Mesh:ON
 ZBrush Map:ON
 Alpha Gain:10

Combining Final Gather or Occlusion with Displacement

Max Ray Offset

The Max Ray Offset is used to avoid incorrect self Occlusion and Final Gather effects when using negative displacements, and can also smooth the displacement detail. A good rule-of-thumb is to set Max Ray Offset to half of the displacement scale if you are using both positive and negative displacements, but leave it at zero if you are using a positive map.

Smooth filter in Final Gather

This parameter will take more gathering points into account when computing the indirect lightning in a given point, and will give a smoother look to surfaces with few gathering points. A displaced surface, however, will contain a large number of gathering points, because of its high frequency varying surface, and in most cases, one wants to keep this detail on the displaced surface, but smooth out the surrounding walls and floor. Therefore, we have added a render stat called smooth final gather to all shape nodes. This is enabled per default, and by unchecking this option for a surface, you disable the final gathering smoothing for this surface, letting you keep the high frequency detail on the displaced surface, and smooth all other part of the scene. Uncheck this render stat on displaced surfaces to optimize render times.  

The head model with Final Gather skylight enabled. The smoothing is disabled on the displaced surface, but enabled at the walls. A max ray offset of half the displacement scale is used.

Return to Tutorial index

Last modified 2006-07-12