Back to Teaching Homepage

Zbrush to Maya Comprehensive Guide:
-Creating and Rendering Displacement Maps, Click HERE
-Creating and Rendering Normal Maps, Click HERE

Software used: Zbrush 3.1, Maya 2008, Photoshop CS3

This tutorial focuses on the process for creating and rendering two primary types of difference maps in the Maya to Zbrush to Maya pipeline. This tutorial uses a single model to demonstrate the similiarities and differences in technique. First we need a little background however:

Heres a site that explains some of the complex stuff: Normal Mapping Tutorial part 1, Normal Mapping Tutorial part 2
Heres the Wiki on Normal Mapping: Wikipedia
Zmapper from Zbrush Central: Zmapper

How do Displacement Maps and Normal Maps differ?????

Displacement maps are going to differ from bump maps based on their ability to create self-shadowing and extend the form past the silhouette and into the surrounding alpha of the render. The are able to do this becuase they are not just a shading illusion like bump maps are, but physically create new polygons at render time. Because of this though, there are several other factors that come in to play to make sure that these extra polys are handled correctly.

Bump maps can actually be broken up into two catagories, Tradditional Height Style Bump Maps (refered to hereafter simply as Bump Maps) and Normal Maps. Both types of maps have one thing in common: they do not effect the object's silhoutte like Displacement maps do. Bump maps a grayscale map to fake the same look that displacement maps actually achieve by creating new geometry by preturbing the surface normals up or down based on the luminence of value of the map applied. Bump Maps versus Normal Maps:

One of the major differences between Bump and Normal maps is they way that space is handled. With a Bump map, as we are all very well familiar with so far, height and depth are determined as a greyscale value with white being high and black being low. Of course, implicit in this formulation is the understanding that height and depth are thusly RELATIVE to each other. For light grey to be high, it has to be higher than dark grey. Without a darker grey area to define how much lower the lowest area should be than the highest areas, we are unable to determine our bumping effect.

Normal Maps work entirely different. Since a specific color value is used to determine the direction which a surface normal is
preterbed, there is no relative effect at play. Thusly Normal Maps are ABSOLUTE in value. Each RGB color points to XYZ space and that value is accurate without having to process their relativity scaling through an external node, which is why they can be processed by Hardware (and thusly are perfect for gaming applications).

Tangent Space Normals versus Object Space Normals versus World Space Normals:

There are three ways to define Normals space, off the Tangent, off the Object, and in relation to the World. To Render Normals in Maya we will need to calculate our maps using the Tangent Space Normals (TSN) configuration. TSNs will calculate the RGB values based on the original direction that each face's normal points. OSNs are calculated based on the the direction the object is positioned in XYZ space. WSNs calculate the vector direction based on the position of the object in world coordinates. These Maps have different uses:

Tangent Space Normals-can work on characters and objects that deform since the vector direction is based on each face
Object Space Normals- can not work on objects that deform since the vector is created off of the pivot point for the object. But, they render faster than TSN, do not exhibit seam problems (which TSNs can), and can be used for non-deforiming moving objects.
World Space Normals- are computed off of the 0,0,0 coordinate of world space and thus can only be used on objects that do not move in any way.

The Major Benefit of normal mapping is that we can create a type of difference map that actually renders in real time. Normal maps use a color value to indicate which vector an object is pointing in. For Tangent Space Normal maps, the RGB Color Value for no deflection (pointing straight up) is 128,128, 255 (or sometimes 127,127, 255), its HEX code is #8080ff.

 

 

Creating and Rendering Displacement Maps
Lets first look at how we can create Displacement for rendering in Maya. Below is an image of our model inside Zbrush. At it's highest level, it is around 4.5 million polygons, allowing a large amount of detail to be present. Of course, this dense of a model would never render in Maya and would be IMPOSSIBLE TO ANIMATE. So what do we do? We create a difference map.

Since we are calculating the difference between the HIGH and LOW poly models, we will need to roll down our Geometry level.
In Tool Palette's Geometry Subpalette, set your SDiv level to level 1.

In Tool-Displacement, set your DPRes to be the size of your map, in this case 2048x2048 pixels (by typing 2048 in the box), make sure that Adaptive and SmoothUV are checked for the best quality map, and hit Create DispMap as seen here:


When the map generates, it will show up in the Alpha Palette. HOWEVER, It does not yet have the correct settings for Maya (also, it is upside down!)

To fix this, we are going to use the Alpha Displacement Exporter. Go to Alpha-DEOptions and in the Quick Code section, you are going to need to configure to one of TWO maya codes. For most purposes we will simply be using 8-bit displacement, but for your convience, the 32-bit code is listed below as well.

FOR 32-BIT FILES: DE-LDEK-EAEAEA-R32

FOR 8-BIT FILES: DE-DDEK-EAEAEA-R8

Circled below is where you can find the DEOptions box. When the code is set, you will notice a full contrast range in your image (and it should be right side up!). Hit Export Current and save the file a TIF. We will use a .tif file for rendering as in Maya 2008, this is again the prefered file format. READ MORE about the great Tiff and Targa wars.

To make sure we are rendering out displacement off of the same model that we created it (since our models in Zbrush tend to change shape at level 1 when sculpting at higher levels), make sure to Export out your tool as an .OBJ. Alternately, switch to a saved morph target before generating the displacement map and skip this step.

Now it's time to reimport the model into maya. This is a crucial step!!!

When Importing, make sure to open the Options Box. Under File Type, Switch from Best Guess to .OBJ.
Then, scroll down in the window till you get to the File Specific Options. UNCHECK "Create Multiple Objects".
If left on, this will screw with your vertex order and could mess up our rendering or future animation needs!!!!!!

Time to add the displacement map. Assign a material to your model (I used a Blinn), and click on the Go To Output connections button, seen below:

This will take you to the Shading Group node. Here you will want to add a Displacement Map. Clicky on the Checker Boxy!

Find your file:

Make sure you are using Mental Ray, and set your Quality Presets to Production.

Hit Render Current Frame!... and OMG, what the Hell happened?????

Don't Panic! What you see based off of the fact that by default, there are several things wrong with Maya's interpretation of Displacement Maps from Zbrush. First of all, we haven't set a scale to determine the relative amount that our Displacement map needs to displace the surface (remember from the theory reading above???). Zbrush creates Alphas with Black as 0 (no change to the surface) and white being 1 (severe change to the surface). Maya does something wholly different. It says that 50% Gray is no change, that Black is a severe downward change, and that white is a severe upward change.

We are going to have to adjust our settings to reference this. Instead of our Alpha Gain being a value of 1 and the Offset being a value of 0, (the default values) we are going to have to make the Gain twice the negative of the Offset Value. See Diagram Below:


As you see in this image, I have gone into the color balance section of my Displacement Map, and Set the Gain at 0.2 and the Offset to -0.1. These values were generated using a guess and check method. Alternately, try using a height field node to narrow in on what you need. The only rule here is that the Gain should always be twice a negative version of the offset. Since this is constant, try using the following espression to generate the changes for you. In the alpha offset field, type:

=-file(#)alphagain/2
If your texture is named file3 you would type =-file3alphagain/2, or if it is file14, it would be =-file14.... and so on.

One of the things you might notice in the render above is that the displacement might still look a little angular around the edges. This is becuase Maya prefers to render displacement off of a subdivisional surface, and not off a polygon mesh. First, we must turn off Maya's regular Feature Displacment however. Select your mesh. Go to the Attribute Editor and click on the Shape Node's Tab. Under Displacement, uncheck Feature Displacement!!!!

Good News Everybody! We can get out mesh to behave as a Subdivision surface with Mental Ray Surface Approximations. We will actually use both Subdiv and Displacement Approximations to generate a smooth surface with which to displace from. In Maya, go to Window--Rendering Editors--Mental Ray--Approximation Editor, as seen below:

 

With the mesh selected, click create for both Displacement and Subdivision. This will assign these approximations.

for Subdivision Approximation, set the Approx method to Spatial which will allow us to set a range of levels with which it can subidivide the model at render time to make it look smoother. I set my range to be no less than 2 and no more than 3, but these values can be adjusted for speed or for quality. I next set my length to 0.100. This value determines the length of the smallest triangle when the model is tesselated. Too small, and your render will take too long. Too big, and you will suffer from poor quality. Next I check the box for View Dependent meaning what we don't see, won't do anything (saving render time). My settings are pretty much the same for the displacement approximation, but for speed I upped the Length to 0.250 (but feel free to change for quality control).

Subdiv: Displacement:

 

And here's my render now, slightly smoother, AND notice how we can see a little more detail in a few of the features (I'm looking at the head crest) and also notice how my render time has DROPPED!!!!! to 0:06 seconds from 0:14 seconds when we started.

HOWEVER, we are not done yet. Maya 2008 presents one last wierd little problem for us. The link below provides information on this phenomenon, and the text from this site is reposted here. BUT, credit where credit is due, so THANK YOU SCOTT SPENCER!!!!!!!!!

"It appears that a lot of people are having problems with Maya 2008 and rendering displacement maps. Two major changes have been made in Maya 2008 that impacts the ability to effectively render 32 bit displacement maps. I did some reasearch and set up a mel script that will set up the scene file correctly. Thanks must go to those who found the problems with Maya 2008 early on. ZBC member marcotronic uncovered the CCMesh change.

The changes that Autodesk made are to the Alpha Detection and the mental Ray export mesh at render time. Maya 8.5 and earlier use Subdivision Surfaces at render time when a subdivision approximation node is assigned. Maya 2008 defaults to the CCMesh or Catmull Clark mesh. This is intended to be faster and support tris, ngons, and quads. The problem is it creates seams in the render.

The second change is to alpha detection. Bloated renders occur because Mental Ray is defaulting to not considering Alpha as luminance.

You can set this manually on each file node or change the default setting under Window>Settings and Preferences>Rendering Use maya style alpha detection.
The script I am posting will throw this switch for the scene file returning it to Maya style alpha detection."

CLICK ON IMAGE BELOW FOR MAYA 2008 INFORMATION:

We are going to run Scott Spencer's script. Copy all of the Green text below:

//COPY THE SCRIPT FROM HERE
// mental ray Subdivision Approximation script

// by scott spencer

//scott@scottspencer.com

//converts all subdivision approximation nodes in the scene from CCMesh to subdivision surface as well as sets the option

// to use maya style alpha detection

optionVar -iv "miUseMayaAlphaDetection" 1 -sv 1 1; //sets maya style alpha detection - mthe same as

// checking the Alpha is Luminance box in the file node but this works for all displacements in the scene

string $selected[] = `ls -type mentalraySubdivApprox`; // selects each subdivision approximation node in the scene and adds to an arry

int $size = `size ($selected)`; // creates the counter variable

for ($a=0;$a<$size;$a++) //increments thru the array

{//beginning of loop

string $name = $selected[$a]; // this variable accesses each element of select using $a as an index

addAttr -ln "miExportCCMesh" -at bool $selected[$a];

}

Open up Maya's Script Editor:

Paste the Text into this window (I decided to list the text above this image... I know... don't email me about it!) Then Highlight all of the text by hitting Ctrl-A.

"Then using the Middle Mouse Button click and drag the text up to the shelf. If you dont see the shelf just press Control and Spacebar to show all the menu elements.Now this button will execute the MEL script when pressed. Just set up you renders as normal and then press this button before rendering. It will make all the changes. You only need to do this once if you save your scene file. It will also support multiple subdivision approximations in a single scene. The script will select and convert each of them.
Make sure to save your preferences so the shelf button stays between Maya sessions. Save prefs with File>Save Preferences "

 

DISPLACEMENT, without Seams!!!! Notice how the crest on the head bulges into the Alpha, changing the form of the model. We will contrast this with our normal maps later on.

This concludes the Displacement mapping section of this tutorial. Continue along for more information on Normal mapping.

For more reading:
DOWNLOAD THE M-ZB-M Displacement Guide for Zbrush 2.0 to Maya 6.5 if you are using older software.

CLICK HERE FOR AN ALTERNATE AND LONGER DISCUSSION OF THE Ma TO Zb TO Ma PIPELINE

RETURN TO TOP

 

Creating and Rendering Normal Maps

Time to examine how to create Normal Maps in Zbrush using Zmapper. We will be using Zmapper's default settings for "Maya Tangent Space Normals--Best Quality". I will first make sure I have a white material (such as the Pearl Cavity) enabled so I can see color change from my map. Switch to the lowest subdivision level for your model.

As state earlier, the default, "no-change value" for a Tangent Space Normal Map is RGB: 127,127,255. In your color palette, set those values now. Notice how your model will change color too!


make a new texture at the desired size (2048 by 2048 in case) and hit new in the Texture Palette. When generated, you should get a blank, periwinkle colored map in your shelf texture palette.

Launch Zmapper.

When Zmapper opens, turn off that god-awful spinning (spin button circled in red below) click on Open Configuration (arrow below).

Choose Maya_TangentSpaceNode_Fast.zmp and say Open.

Up the Samples and Subdivide to Maximize quality. The more you up these values, the more RAM your computer will need and the longer the process of generating the map will take.

In the Expert Pass 2 tab, crank up all the sliders on the top row. This helps to precent small seam errors in your map when rendering. (we will see this soon).

Return to the Normal & Cavity Map tab and Hit Create Normal Map (the big chunky button). After a few seconds, minutes, or hours, you will see your low poly model with a generated Normal Map applied to it. Hit Exit...

Now Your map will show up (right side up) in the Texture Palette and will be applied to your model (upside down). This map is ready for export. It will save as a .PSD.

Open the map in Photoshop and save it as a .tif of .tga.

Return to Maya (importing the model the same as above in the displacement section of this tutorial). In the Material node (my Blinn), click on the checker box for Bump Mapping.

Locate a file node.

Once in, set your Use As: to Tangent Space Normals.

Load your file.

AGAIN, make sure you are using Mental Ray to render and that you are at Production Quality:

And BAM! Normal Map. This time around though, notice how the map doesn't actually influce the edge of the model. When we view the alpha, we cannot see evidence of the crest at all!

Most importantly, since we cranked up those settings in the expert pass 2 section, we should have a seamless application:

This concludes the Normal Mapping Section of our tutorial.

RETURN TO TOP