Displacement mapping
Contents
Introduction
This tutorial shows the method of creating a displacement map. In the following example we use a simple checker texture on a MIA material. Of course this method will also work when you are using other materials (such as blinn and lambert), and when you are applying file textures.
Creating a displacement map
Start by creating a new material and assigning it to the object for which you want to create a displacement map. Here we use a polygonal plane with a size of 10 x 10 units.
Go to Window > Rendering Editors > Hypershade
Create a new material. In this case we choose ‘mia_material_x’. Select the newly created shader, rename it and adjust its settings according to your needs. Assign the material to your object.
Select the object in your model viewport. In the Hypershade, press and hold the right mouse button on your shader, then drag it up to select Assign Material to Selection in the quick menu.
Displacement works using grayscale textures (in the same way as bump and reflection for example). All white areas on your texture will result in maximum displacement, black parts will remain unaltered and gray tones cover the range in between. Displacement maps aren’t directly applied to the shader; instead they are connected to the shading group.
Select your material in the Hypershade. Click (Input and output connections) to reveal the shader network. Then select the shading group node in the work area. The name of the shading group ends with "SG". Depending on the kind of material you use its name will look like ‘mia_material_x1SG’ or ‘lambert2SG’.
Open the Attribute Editor tab of the shading group. Here you can assign a texture to use as displacement map. Click on the checkerbox behind Displacement mat.
The node creation window pops up. You can select built-in procedural textures or use file textures instead (in which case you have to choose a ‘File’ node). For now we will use a ‘Checker’.
Having chosen a texture, Maya will automatically create a displacement node and connect it to the shading group. To check if your shading network is correct, select the shading group node and click Input and output connections once more. The network should look like this:
Make a test render.
Making adjustments
If you render the scene the displacement will be applied to the geometry and show up in your final image. However, it may not be entirely accurate yet.
As you can see in the following render the displaced geometry has some jagged edges and could be warped as well (results may vary). To fix this behavior you need to increase the amount of subdivisions in your object.
For example [Polygons] > Edit Mesh > Insert Edge Loop Tool allows you to quickly add multiple edges to your object.
Otherwise you can use [Polygons] > Edit Mesh > Interactive Split Tool. With this tool you can cut faces by drawing points on the edges of your object.Increasing the amount of subdivisions leads to a more accurate displacement. However, render time will increase as well. It is thus advised to keep them as low as possible. You can do this by making a few test renders of critical regions in your image, increasing the subdivisions slowly between each attempt until results are satisfactory.
Finally the height of the displacement needs to be adjusted. This has to be done in the settings of your displacement texture (which in our example is the ‘Checker’).
Select your texture (in the Hypershade) and open the Attribute Editor tab. Under Color Balance, look up Alpha Gain. The alpha gain value determines the maximum displacement. By default it is set to 1. This corresponds to an outwards translation of 1 unit in your model for the white blocks of our checker pattern.
Baking displacement texture
Maya offers the option to turn displacement into real geometry which can be viewed and modified in your model viewport.
To do this go to Modify > Convert > Displacement to Polygons
In order for the conversion to work Maya will look for a surface material attached to your shading group. This is done by default for blinn, lambert and phong shaders. With MIA materials however it isn’t, so you’ll have to attach a surface material manually.
Open the Hypershade. With your middle mouse button, click and drag ‘lambert1’ over the shading group node. Release and choose Default. This attaches the default gray shader as a surface material. Displacement to Polygons should now work without error.